Forum Discussion
Get previous month / previous year using calculation groups
- 2 years ago
I would go with Field Parameters and independent measures.
Hi lbendlin , the client wants to compare the values generated from Slicer A from Slicer B.
I was able to create a Calculation group with for Slicer A with the following measures:
KEEPFILTERS (DATESINPERIOD ( 'dim_date'[date], __date - 1, -7, DAY ) ) ) )
VAR __Result =
&& 'al_pres_dimad dim_date'[date] <= _todaymonthend - 1 )))
and this is the measure I created for Slicer B
//for Primary vs Month on Month calculations
var _last7DaysMoM = CALCULATE([Actual],DATEADD('dim_date'[date],-1,MONTH))
var _mtdMoM = CALCULATE([Actual], DATEADD('dim_date'[date],-1,MONTH))
var _lastMonthMoM = CALCULATE([Actual], PARALLELPERIOD('dim_date'[date],-1,MONTH))
var _ytdMoM = CALCULATE( [Actual], DATEADD('dim_date'[date],-1,MONTH))
//for Primary vs Year on Year calculations
var _last7DaysYoY = CALCULATE([Actual], DATEADD('dim_date'[date],-1,YEAR))
var _mtdYoY = CALCULATE( [Actual ],DATEADD('dim_date'[date],-1,YEAR))
var _lastMonthYoY = CALCULATE( [Actual],PARALLELPERIOD('dim_date'[date],-1,YEAR))
var _ytdYoY = CALCULATE([Actual], DATEADD('dim_date'[date],-1,YEAR))
For the Slicer B, I was able to make it work for the Last 7 Days and FYTD and got the desired results. However, I am having issues with MTD and Last Month since it's returning blank values for the Slicer B.
My follow up question is, should I adjust the calculation I have in Slicer A for the MTD and Last Month? or should I change the DATEADD dax function I used for the Slicer B?
I would go with Field Parameters and independent measures.
- Anonymous2 years agoNot applicable
Thank you! This works for my report.