Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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
User | Count |
---|---|
13 | |
8 | |
8 | |
7 | |
5 |
User | Count |
---|---|
21 | |
15 | |
15 | |
10 | |
7 |