Forum Discussion
Need help with Rolling Sum
- 5 years ago
Hi, Anonymous
Try to create a measure like this:
Rolling Average Numerator = VAR _sum12 = CALCULATE ( SUM ( 'PowerBI(Index)'[Total Return Numerator ("calculated reutrn" tab, Column K)] ), FILTER ( ALL ( 'PowerBI(Index)' ), EOMONTH ( 'PowerBI(Index)'[Return_id], 0 ) <= EOMONTH ( MAX ( [Return_id] ), 0 ) && EOMONTH ( 'PowerBI(Index)'[Return_id], 0 ) > EOMONTH ( MAX ( [Return_id] ), -12 ) ) ) RETURN IF ( HASONEVALUE ( 'PowerBI(Index)'[Return_id] ), _sum12, SUM ( 'PowerBI(Index)'[Total Return Numerator ("calculated reutrn" tab, Column K)] ) )my sample data:
Please refer to the attachment below for details
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Anonymous
Try to create a measure like this:
Rolling Average Numerator =
VAR _sum12 =
CALCULATE (
SUM ( 'PowerBI(Index)'[Total Return Numerator ("calculated reutrn" tab, Column K)] ),
FILTER (
ALL ( 'PowerBI(Index)' ),
EOMONTH ( 'PowerBI(Index)'[Return_id], 0 ) <= EOMONTH ( MAX ( [Return_id] ), 0 )
&& EOMONTH ( 'PowerBI(Index)'[Return_id], 0 )
> EOMONTH ( MAX ( [Return_id] ), -12 )
)
)
RETURN
IF (
HASONEVALUE ( 'PowerBI(Index)'[Return_id] ),
_sum12,
SUM ( 'PowerBI(Index)'[Total Return Numerator ("calculated reutrn" tab, Column K)] )
)
my sample data:
Please refer to the attachment below for details
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years agoNot applicable
Thanks Zeon! it worked!
- Anonymous5 years agoNot applicable
Hey Zeon,
Actually I have one more question, my page has slicers but when the FILTER ALL function is used it overrides the slicer filtering. Is there a way to still calculate rolling summation without the filter all function?
- v-angzheng-msft5 years agoCommunity Support
Hi, Anonymous
just replace ALL with AllSELECTED like this:
code:
Rolling Average Numerator = VAR _sum12 = CALCULATE ( SUM ( 'PowerBI(Index)'[Total Return Numerator ("calculated reutrn" tab, Column K)] ), FILTER ( ALLSELECTED ( 'PowerBI(Index)' ), EOMONTH ( 'PowerBI(Index)'[Return_id], 0 ) <= EOMONTH ( MAX ( [Return_id] ), 0 ) && EOMONTH ( 'PowerBI(Index)'[Return_id], 0 ) > EOMONTH ( MAX ( [Return_id] ), -12 ) ) ) RETURN IF ( HASONEVALUE ( 'PowerBI(Index)'[Return_id] ), _sum12, SUM ( 'PowerBI(Index)'[Total Return Numerator ("calculated reutrn" tab, Column K)] ) )Best Regards,
Community Support Team _ Zeon Zheng- Anonymous5 years agoNot applicable
Thanks Zeon your the best!!!