Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I'm a biginer in Power BI, so please ignore silly mistakes.
I have tried below DAX calculation to calculate the running avg using windows and it does not work.
Thanks,
Nawaz
Solved! Go to Solution.
Hi @Nawaz
Thanks for the reply from @Greg_Deckler , please allow me to provide another insight:
Here I create a set of sample:
Then create 2 measures:
SUM_Sales =
VAR _currentCa =
SELECTEDVALUE ( 'Table'[Category] )
RETURN
CALCULATE (
SUM ( 'Table'[sales] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Category] = _currentCa )
)
AVG =
VAR _vtable =
SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Category], "_SUM", [SUM_Sales] )
VAR _vtable2 =
ADDCOLUMNS ( _vtable, "_sort", RANKX ( _vtable, 'Table'[Category],, ASC ) )
VAR _vtable3 =
ADDCOLUMNS (
_vtable2,
"_AVG",
AVERAGEX (
FILTER (
_vtable2,
[_sort] <= EARLIER ( [_sort] )
&& [_sort]
>= EARLIER ( [_sort] ) - 1
),
[_SUM]
)
)
RETURN
MAXX (
FILTER ( _vtable3, [Category] = SELECTEDVALUE ( 'Table'[Category] ) ),
[_AVG]
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Nawaz
Thanks for the reply from @Greg_Deckler , please allow me to provide another insight:
Here I create a set of sample:
Then create 2 measures:
SUM_Sales =
VAR _currentCa =
SELECTEDVALUE ( 'Table'[Category] )
RETURN
CALCULATE (
SUM ( 'Table'[sales] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Category] = _currentCa )
)
AVG =
VAR _vtable =
SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Category], "_SUM", [SUM_Sales] )
VAR _vtable2 =
ADDCOLUMNS ( _vtable, "_sort", RANKX ( _vtable, 'Table'[Category],, ASC ) )
VAR _vtable3 =
ADDCOLUMNS (
_vtable2,
"_AVG",
AVERAGEX (
FILTER (
_vtable2,
[_sort] <= EARLIER ( [_sort] )
&& [_sort]
>= EARLIER ( [_sort] ) - 1
),
[_SUM]
)
)
RETURN
MAXX (
FILTER ( _vtable3, [Category] = SELECTEDVALUE ( 'Table'[Category] ) ),
[_AVG]
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Nawaz Try one of these approaches. Better Rolling Average - Microsoft Fabric Community
Or this one, just replace SUMX with AVERAGEX: Better Running Total - Microsoft Fabric Community
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 16 | |
| 8 | |
| 7 | |
| 7 |