Forum Discussion
bharatsrini123
4 years agoRegular Visitor
Calculate last 5 weeks rolling average.
Hi I am trying to calculate last 5 weeks rolling average of sum of a set of values and divide it by the last 5 weeks rolling average of count of the same set of values. I did it using a normal calcul...
- 4 years ago
Hi bharatsrini123 ,
Please try the measure.
last 5 weeks rolling average = VAR tab = FILTER ( ALL ( 'Calendar' ), 'Calendar'[Week] > MAX ( 'Calendar'[Week] ) - 5 && 'Calendar'[Week] <= MAX ( 'Calendar'[Week] ) ) VAR Ave_Sum = AVERAGEX ( SUMMARIZE ( tab, 'Calendar'[Week] ), CALCULATE ( SUM ( 'Table'[Values] ) ) ) VAR Ave_Count = AVERAGEX ( SUMMARIZE ( tab, 'Calendar'[Week] ), CALCULATE ( COUNT ( 'Table'[Values] ) ) ) RETURN DIVIDE ( Ave_Sum, Ave_Count )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-kkf-msft
4 years agoCommunity Support
Hi bharatsrini123 ,
Please try the measure.
last 5 weeks rolling average =
VAR tab =
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Week]
> MAX ( 'Calendar'[Week] ) - 5
&& 'Calendar'[Week] <= MAX ( 'Calendar'[Week] )
)
VAR Ave_Sum =
AVERAGEX (
SUMMARIZE ( tab, 'Calendar'[Week] ),
CALCULATE ( SUM ( 'Table'[Values] ) )
)
VAR Ave_Count =
AVERAGEX (
SUMMARIZE ( tab, 'Calendar'[Week] ),
CALCULATE ( COUNT ( 'Table'[Values] ) )
)
RETURN
DIVIDE ( Ave_Sum, Ave_Count )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.