Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I have an issue with a rolling average I created with DAX in a line chart. The first 4 days are deflated because it's still thinking I want a 5 day average for the first 1, 2, 3, and 4 days...
Here is the DAX:
Solved! Go to Solution.
Hi @jconte12 ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
rank = RANKX(ALL('Table'),'Table'[date],,ASC)
mod =
var _mod=MOD('Table'[rank],5)
return
IF(
_mod=1,1,0)
Group =
CALCULATE(SUM('Table'[mod]),FILTER(ALL('Table'),'Table'[date]<=EARLIER('Table'[date])))
2. Create measure.
Measure =
var _1=MAX('Table'[Date])
return
AVERAGEX(
FILTER(
SUMMARIZE(ALL('Table'),
'Table'[Date],'Table'[Group],
"Avg value",AVERAGE('Table'[amount])),
'Table'[Date]<=_1&&'Table'[Group]=MAX('Table'[Group])),
[Avg value])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @jconte12 ,
I created some data:
Here are the steps you can follow:
1. Create calculated column.
rank = RANKX(ALL('Table'),'Table'[date],,ASC)
mod =
var _mod=MOD('Table'[rank],5)
return
IF(
_mod=1,1,0)
Group =
CALCULATE(SUM('Table'[mod]),FILTER(ALL('Table'),'Table'[date]<=EARLIER('Table'[date])))
2. Create measure.
Measure =
var _1=MAX('Table'[Date])
return
AVERAGEX(
FILTER(
SUMMARIZE(ALL('Table'),
'Table'[Date],'Table'[Group],
"Avg value",AVERAGE('Table'[amount])),
'Table'[Date]<=_1&&'Table'[Group]=MAX('Table'[Group])),
[Avg value])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @jconte12 , Here's another example for moving average if that might help?
User | Count |
---|---|
103 | |
87 | |
77 | |
70 | |
69 |
User | Count |
---|---|
113 | |
99 | |
97 | |
72 | |
68 |