Forum Discussion
30 day rolling average
Hi
Would anyone be able to help me convert this formula into a "last 30 day rolling average"? I seem to be going in circles.
Thank you in advance!
- Anonymous4 years ago
Hi Anonymous ,
I think you can try this code.
Turnover Rolling Avg. Calc. (€) 2 = CALCULATE ( AVERAGE ( onetouch_daily_account_summary_last_2_months[bet_eur] ), FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) && 'Calendar'[Date] > MAX ( 'Calendar'[Date] ) - 30 ) )Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
9 Replies
- Samarth_18Community Champion
Hi Anonymous ,
You can try below code:-
Turnover Rolling Avg. Calc. (€) = AVERAGEX ( FILTER ( ALLSELECTED ( 'Calendar' ), DATESINPERIOD ( 'Calendar'[Date], MAX ( 'Calendar'[Date] ), -30, DAY ) ), CALCULATE ( onetouch_daily_account_summary_last_2_months[Turnover (€)] ) )Thanks,
Samarth
- AnonymousNot applicable
- Samarth_18Community Champion
Anonymous Try this:-
Turnover Rolling Avg. Calc. (€) = CALCULATE ( AVERAGE ( onetouch_daily_account_summary_last_2_months[Turnover (€)] ), ALL ( 'Calendar' ), DATESINPERIOD ( 'Calendar'[Date], MAX ( 'Calendar'[Date] ), -30, DAY ) )
- AnonymousNot applicable
Samarth_18 So now there is no error message, but the result is blank. hmm.
i did have to change the reference for this part, to the column, and not the measure, for it to accept it.
AVERAGE ( onetouch_daily_account_summary_last_2_months[Turnover (€)] )changed toAVERAGE ( onetouch_daily_account_summary_last_2_months[bet_eur] ) - ALLUREANSolution Sage
Hi, Anonymous
You can try this one:
Turnover Rolling Avg. Calc. (€) =
VAR NumOfDays = 30
VAR LastCurrentDate = MAX ( 'Calendar'[Date] )
VAR Period = DATESINPERIOD ( 'Calendar'[Date], LastCurrentDate, - NumOfDays, DAY )
VAR Result =
CALCULATE (
AVERAGEX (
VALUES ( 'Calendar'[Date] ),
onetouch_daily_account_summary_last_2_months[bet_eur]), Period)RETURN
Result