I am making a report that counts the amounts of offers, uniquely identified with SALE_ID, containing data from different products starting first of January 2015 ranging up to todays date (18/12/2017 at the time of asking). I am counting the amounts of offers with a simple measure called 'Distinct':
Distinct := DISTINCTCOUNT(dOffers[Sale_ID])
This gives me satisfactory results, as in, I am receiving the right counts for the considered period. I am also calculating year-over-year changes, defining the previous year offers with the following measure: (dCalendar contains the datekey table).
PY Offers :=
SUMX (
VALUES ( dCalender[YearMonthNumber] );
IF (
CALCULATE ( COUNTROWS ( VALUES ( dCalender[FullDates] ) ) )
= CALCULATE ( VALUES ( dCalender[MonthDays] ) );
CALCULATE (
[Distinct];
ALL ( dCalender );
FILTER (
ALL ( dCalender[YearMonthNumber] );
dCalender[YearMonthNumber]
= EARLIER ( dCalender[YearMonthNumber] ) - 12
)
);
CALCULATE (
[Distinct];
ALL ( dCalender );
CALCULATETABLE ( VALUES ( dCalender[MonthDayNumber] ) );
FILTER (
ALL ( dCalender[YearMonthNumber] );
dCalender[YearMonthNumber]
= EARLIER ( dCalender[YearMonthNumber] ) - 12
)
)
)
)
The problem that I am having, is that the year-over-year change for the month december (the running month), considers the year-to-date sales for this year (2017) and compares this to full month sales in the previous years (2016 and 2015); this makes the last months comparison uninterpretable, as we are comparing offers from half a month to offers from a full month.
I would like to know how to fix this problem: i.e. consider the sales for the full year up to todays date, and compare this for the exact same periods last year and two years ago (2015: start Jan 1st and go up to Dec 18th; idem dito for 2016 and 2017). The SAMEPERIODLASTYEAR call might seem straightforward forthis issue, but I am receiving a contiguous dates errors...
Thanks in advance!