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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
mdbuzzer
Helper I
Helper I

How do you calculate the rolling average per week/month?

I have bins created from my date field which gets the daily group. 

Is there a way to calculate the weekly average, so for example from April 1st to April 7th it should have an average of 16.2 (excludes cells containing 0).

 

mdbuzzer_0-1604655145463.png

So for an output I am looking for it to show Week Commencing April 1st then display the average of 16.2, then Week Commencing April 8th to display 27, and so forth.

 

Thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mdbuzzer ,

 

1.Create three calculated columns.

weeknum = WEEKNUM([Date],2)
Average = CALCULATE(AVERAGE('Table'[Value]),ALLEXCEPT('Table','Table'[weeknum]))
week = WEEKDAY([Date],2)

1.png

 

2.Create a new table and create a relationship with main table.

Table 2 = FILTER('Table',[week]=3)

 2.png

 

3.Create a calculated column in the new table.

Rolling average = CALCULATE(SUM('Table 2'[Average]),FILTER(ALL('Table 2'),[Date]<=EARLIER('Table 2'[Date])))

3.png

 

4.The result is as follows.

4.png

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @mdbuzzer ,

 

1.Create three calculated columns.

weeknum = WEEKNUM([Date],2)
Average = CALCULATE(AVERAGE('Table'[Value]),ALLEXCEPT('Table','Table'[weeknum]))
week = WEEKDAY([Date],2)

1.png

 

2.Create a new table and create a relationship with main table.

Table 2 = FILTER('Table',[week]=3)

 2.png

 

3.Create a calculated column in the new table.

Rolling average = CALCULATE(SUM('Table 2'[Average]),FILTER(ALL('Table 2'),[Date]<=EARLIER('Table 2'[Date])))

3.png

 

4.The result is as follows.

4.png

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Perfect! Thank you, that's exactly what I was looking for

amitchandak
Super User
Super User

@mdbuzzer  ,

a measure like

AverageX(filter(Table, Table[Col]>0),Table[Col])

 

For week wise data you can have columns like 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)

Measures
This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
Last 8 weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-8 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

last two weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]<=max('Date'[Week Rank])-1

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

not sure i'm getting the right result.

Below are the figures for Week 14 so the average of these values should equal 25.2

mdbuzzer_0-1604659568341.png

But it's returning an average of 3 for Week 14

mdbuzzer_1-1604659637426.png

 

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.