Forum Discussion
Rickstor
3 years agoFrequent Visitor
Moving Average 5 periods
Hello. Please help me. I need a moving average, 5 periods, in Power BI, using a measure. This is so easy in Microsoft Excel. I need this: The column 'year' has a text format. After se...
- 3 years ago
pls try this
5 step 3 = VAR _CurentRx = MAX('data'[Rx]) VAR _Results = CALCULATE(SUM(data[value]), FILTER(ALL(data),'data'[Rx]<=_CurentRx&&'data'[Rx]>=_CurentRx-4), VALUES(data[cod_region])) /5 RETURN IF(_CurentRx< 6 , BLANK(),_Results)
Rickstor
3 years agoFrequent Visitor
Hi Ahmedx , almost done! Works great whitout 'code_region'. When I add this column, the values are the same for all regions. Like this:
using only 'year' it's great, it's working!
I tried change the ALL() to ALLSELECTED(), but doesn't work.
What's missing?
Thank you for your help.
Ahmedx
Super User
3 years agopls try this
5 step 3 =
VAR _CurentRx = MAX('data'[Rx])
VAR _Results = CALCULATE(SUM(data[value]), FILTER(ALL(data),'data'[Rx]<=_CurentRx&&'data'[Rx]>=_CurentRx-4), VALUES(data[cod_region])) /5
RETURN
IF(_CurentRx< 6 , BLANK(),_Results)