Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Moving Average based on Weeks. Slicers and sums

Goodday,

 

I have been trying for some time to make a moving average based on a Year-Week Hierarchy in a chart that listens to slicers. 

Sadly most of the posts on here that i find i can't seem to get working.

 

I have a chart that shows the amount ("Uur gedaan") for every week, based on the Year-Week hierarchy. This chart has slicers that change the data underneath based on other factors. 

JemKoel_1-1657111721188.png

I am trying to add a moving average of the past 6 weeks, that updates if i select something in the slicers.

 

The closest that i got was https://community.powerbi.com/t5/Desktop/Calculate-weekly-moving-average/m-p/530379.

But this just ends up always giving the current value divided by 6, instead of all past 6 values divided by 6. 

 

The table with the Amount has a Year Column, a Week Column and a Year-Week Concatenate to make a unique one for every year week Combo. My Date table has all 3 of these as well. The "Uur Gedaan" Column is summed up to the total for that week in the graph. 
Even then i am still unable to get it to work. Do you guys have any tips?

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , A measure like this usinf week rank column

 

Avg Last 6 weeks = CALCULATE(Averagex(Values('Date'[Week Rank]), [orders ]) , FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-6 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

 

 

Use separate week/date table with a column like

 

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@amitchandak You are magnificant, thank you very much!

 

JemKoel_0-1657626864288.png

 

Anonymous
Not applicable

Hello Amitchandak, 

 

Thank you for your reply. I had my doubts about making a new column because those generally don't work if the data is spread over multiple rows. I will try to implement this solution next week and after that mark this as solved or reply if it hasnt been sovled yet 🙂

amitchandak
Super User
Super User

@Anonymous , A measure like this usinf week rank column

 

Avg Last 6 weeks = CALCULATE(Averagex(Values('Date'[Week Rank]), [orders ]) , FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-6 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

 

 

Use separate week/date table with a column like

 

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.