Reputation: 21
I have monthly results that I need to present as a 3 month rolling average, sometimes at a monthly level and sometimes as a sum of the 3 month rollling average for the quarter/year.
At the monthly level I've found the below formula to work well:
3-Mo Rolling Avg = CALCULATE([Market Performance], DATESINPERIOD(Calendar_Lookup[date], MAX(Calendar_Lookup[date]), -3, MONTH))
/ CALCULATE(DISTINCTCOUNT(Calendar_Lookup[Year_Month]), DATESINPERIOD(Calendar_Lookup[date], LASTDATE(Calendar_Lookup[date]), -3, MONTH))
But, when I show quarterly or annual results it shows one 3 month average instead of a sum of the 3 month averages for the period. How would you solve this?
The options I can see are:
Create a column in either Power Query or DAX that holds the 3 month averages so then I can SUM them as needed? Any advice on how to do this?
Figure out how to do a SUM of a measure. Any advice on how to do this?
Build a series of measures at the monthly, quarterly and annual level. Not a great solution as it doesn’t allow me to work fast when performing analysis because I have to be careful of pulling the right measure.
Any advice would be appreciated! Thanks!
Upvotes: 1
Views: 4102
Reputation: 541
But, when I show quarterly or annual results it shows one 3 month average instead of a sum of the 3 month averages for the period. How would you solve this?
Based on this part, it sounds like you need one of the iterator functions. In this case it sounds like a SUMX
The basic layout would be something along the lines of
Measure:= SUMX( VALUES(Calendar_Lookup[Year_Month] ) , [3-Mo Rolling Avg] )
This measure would first using VALUES function generate a distinct list of each [Year_Month]. It would then calculate using your existing [3-Mo Rolling Avg] for each [Year_Month] and then sum the results.
Upvotes: 3