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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate average across rolling previous 4 rows

Hi,

 

I have a table containing the value count of rows over a grouped year/week column. I have sorted the data by year/week ascending:

 

CountRef | Year Week Sort

6                201831

4                201832

9                201833

13              201834

17              201835

7                201836

15              201837

21              201838

 

I need to calculate the average value across the rolling previous 4 rows. For example, the average across: 21+15+7+17, then 13+9+4+6 and so on....

 

Any help appreciated.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Perhaps:

 

Column = AVERAGEX(FILTER(ALL(Table12),[Year Week Sort]>=EARLIER([Year Week Sort])-3),[CountRef])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Perhaps:

 

Column = AVERAGEX(FILTER(ALL(Table12),[Year Week Sort]>=EARLIER([Year Week Sort])-3),[CountRef])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

This works for me:

 

Column = AVERAGEX(FILTER(ALL(Table12),([Year Week Sort]>=EARLIER([Year Week Sort])-3) && [Year Week Sort] <= EARLIER([Year Week Sort])-0),[CountRefs])

 

Thanks!

I have a requirement somewhat similar to this...I need to find the latest running average velocity for the last 3 sprints. 

 

This is the error I get when I try to use the same formular as listed to at least start calculating the averages.

Any idea what I could be doing wrong?Error

PowerbiError.PNG

 

Anonymous
Not applicable

Thanks for your reply.

 

 This seems to work for the first average but the averages following this aren't correct. The output I expect is:

 

CountRef | Year Week Sort | Avg

6                201831               

4                201831

9                201831

13              201831

17              201831                  10.75

7                201831                  11.5

15              201831                  13

21              201831                  15  

 

Thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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