Forum Discussion
Anonymous
5 years agoNot applicable
Rolling 3 months Average
Hi everyone. I have encounter an issue on my report and need your help. I need a calculation of Trend and it's definition is: Average of the last 3 months of the month selected. If my slice...
ERD
Community Champion
5 years agoHello Anonymous ,
To get the average value for the last 3 months (starting from the chosen one in slicer), you'll need to have a proper calendar table (including dates for 2020 and 2021 upon the example) and the next measure:
EDITED upon the next comment
Trend =
IF(HASONEVALUE(Calendar[Date]),
CALCULATE(
AVERAGE(DataTable[Value]),
DATESINPERIOD(
Calendar[Date],
SELECTEDVALUE(Calendar[Date]),
-3, MONTH)
),
AVERAGE(DataTable[Value]))
Anonymous
5 years agoNot applicable
Hi ERD
Your usage of the time-intel functions is incorrect and will often yield wrong values. Please refer to this guide to understand when you can correctly use them: DATESINPERIOD – DAX Guide. A hint would be: You cannot use time-intel functions with fact tables. You have to have a proper date/calendar table (dimension) to be safe.
- ERD5 years ago
Community Champion
Thanks for the hint! Edited previous advise.