This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
hello, I am looking to caluclate 4 week moving average on this data set. I want to get the moving average per platform (group)
can someone pls help me how i can do this?
you can see the excel table below with the 4wma calculated per platform from wk44 to wk06. how can i do this in powerbi?
Thanks for your help. Appreciate it...
| YYWW* | Value | Platform | 4WMA |
| 2444 | 1.587302 | A | 1.587302 |
| 2445 | 0.198413 | A | 0.892857 |
| 2446 | 1.388889 | A | 1.058201 |
| 2447 | 0.992063 | A | 1.041667 |
| 2448 | 0 | A | 0.644841 |
| 2449 | 0 | A | 0.595238 |
| 2450 | 0 | A | 0.248016 |
| 2451 | 0 | A | 0 |
| 2452 | 0 | A | 0 |
| 2501 | 0 | A | 0 |
| 2502 | 0 | A | 0 |
| 2503 | 18.60119 | A | 4.650298 |
| 2504 | 5.803571 | A | 6.10119 |
| 2505 | 13.07292 | A | 9.36942 |
| 2506 | 2.752976 | A | 10.05766 |
| 2507 | 1.264881 | A | 5.723586 |
| 2444 | 0 | B | 0 |
| 2445 | 0.297619 | B | 0.14881 |
| 2446 | 0 | B | 0.099206 |
| 2447 | 0 | B | 0.074405 |
| 2448 | 0 | B | 0.074405 |
| 2449 | 0 | B | 0 |
| 2450 | 0 | B | 0 |
| 2451 | 0 | B | 0 |
| 2452 | 0 | B | 0 |
| 2501 | 0 | B | 0 |
| 2502 | 0 | B | 0 |
| 2503 | 2.083333 | B | 0.520833 |
| 2504 | 5.555556 | B | 1.909722 |
| 2505 | 0 | B | 1.909722 |
| 2506 | 2.380952 | B | 2.50496 |
| 2444 | 0 | C | 0 |
| 2445 | 0 | C | 0 |
| 2446 | 0 | C | 0 |
| 2447 | 0.297619 | C | 0.074405 |
| 2448 | 0 | C | 0.074405 |
| 2449 | 0 | C | 0.074405 |
| 2450 | 0 | C | 0.074405 |
Solved! Go to Solution.
you can also try to this
1. create an order column
Proud to be a Super User!
you can also try to this
1. create an order column
Proud to be a Super User!
Thanks a lot @ryan_mayu Ryan. I was exactly trying to do that... create an index first and create moving average .. but i was struggling. thanks for the solution.. i really appreciate it..
you are welcome
Proud to be a Super User!
Hi @ZubinB please try this
Thanks @techies for helping.. I tried your solution. it is returning me all zeroes. Dont know why. Thanks for the help. I already got the solution from @ryan_mayu
Hi @ZubinB
Assuming that the four weeks can cross between two years, you will need a separate weeks table that has a column of the weeks' chronological order as you can't simply subtract 3 from the current week. Assuming also that there are only 52 weeks in a year, create this calculated table and relate it to your fact.
Weeks =
VAR _Weeks =
SELECTCOLUMNS ( GENERATESERIES ( 1, 52, 1 ), "Week", [Value] )
VAR _year =
SELECTCOLUMNS ( { 2024, 2025 }, "Year", [Value] )
VAR _crossjoined =
ADDCOLUMNS (
CROSSJOIN ( _year, _Weeks ),
"YYWW", VALUE ( RIGHT ( [Year], 2 ) & FORMAT ( [Week], "00" ) )
)
RETURN
ADDCOLUMNS (
_crossjoined,
"Order", RANKX ( _crossjoined, [YYWW],, asc, DENSE )
)
Create this measure:
4 WMA =
VAR _period =
FILTER (
ALL ( Weeks ),
Weeks[Order]
>= MAX ( Weeks[Order] ) - 3
&& Weeks[Order] <= MAX ( Weeks[Order] )
)
VAR _AVG =
AVERAGEX ( _period, CALCULATE ( SUM ( 'Table'[Value] ) ) )
RETURN
_AVG
Please see the attached sample pbix.
If this isn't what you're looking for, please provide more details as we'll just end up with assumptions.
Hi @Abhilash_P
Thank you for taking the time in answering the question.
It didn't return any error but it dint give any numbers. it created 4WMA column with blanks.
what am i doing wrong? sorry im a beginner in powerbi..
Thanks
Hi @ZubinB ,
Can you check with below DAX function
4WMA =
VAR CurrentWeek = SELECTEDVALUE('Table'[YYWW]) -- To Get current YYWW
VAR CurrentPlatform = SELECTEDVALUE('Table'[Platform]) -- To Get current Platform
RETURN
CALCULATE(
AVERAGE('Table'[Value]),
FILTER(
ALL('Table'),
'Table'[Platform] = CurrentPlatform &&
'Table'[YYWW] <= CurrentWeek &&
'Table'[YYWW] > CurrentWeek - 4
)
)
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 30 | |
| 28 | |
| 23 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 48 | |
| 46 | |
| 41 | |
| 21 | |
| 18 |