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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
v-stephen-msft
Community Support
Community Support

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
v-stephen-msft
Community Support
Community Support

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

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.