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

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
Community Champion
Community Champion

Perhaps:

 

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


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Perhaps:

 

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


Follow on LinkedIn
@ 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!:
DAX For Humans

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
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors