Forum Discussion
Rolling average last 3 months
- Anonymous6 years ago
How about this?
Rolling Average 3 months = VAR LastDate_ = LASTDATE ( Table[Calendar Day] ) RETURN CALCULATE ( AVERAGEX ( VALUES ( 'Table'[Month] ); CALCULATE ( SUM ( 'Table'[Sales] ) ) ); FILTER ( ALL ( Table ); [Calendar Day] <= LastDate_ && [Calendar Day] > DATEADD ( LastDate_; -3; MONTH ) ) )Similar to yours, but i changed the table for AVERAGEX to iterate over to the month values. Also changed the calcualte filter a little bit.
- 6 years ago
Excellent Ulf, that solved it 🙂
Thanks.
Yes, it's because of ALL(Table) in the filter. All filters are removed to be able to access previous months. It should be possible to modify the CALCULATE / FILTER expression to only remove the filters on date/year/month. To do that easier and better I suggest creating a connected date table instead of having the date columns in the "fact" table. Dimensional models are usually easier to work with in Power BI! Then you can do the same thing as now but on the date table - ALL([NewDateTable]) instead of ALL(Table).
Excellent Ulf, that solved it 🙂
Thanks.
- Anonymous6 years agoNot applicable
Good to hear the problem is solved! By the way, you should mark my answer as the answer, not your own post... 🙂