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
Jaf017
Helper I
Helper I

Rolling Average of Last 8 Weeks

I've tried numerous different ways of calculating a rolling 8 week average, but just can't seem to get it to work.

 

Through my errors I've experienced a result of the average being the same value of the week, blank, or all the same value for every location.

Below is a sample of my data, date key, and my datamodel. Also one of the DAX formulas I've used.

Data ModelData ModelData SampleData SampleDate KeyDate Key

 

8 Week Avg Cases =
CALCULATE (
AVERAGEX ( 'Summary', 'Summary'[_Cases] ),
DATESINPERIOD (
'Date Key'[WE],
LASTDATE ( 'Date Key'[WE] ),
-56,
DAY
)
)
Any help on this would be greatly appreciated.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Jaf017 , Refer my blog for that

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Rolling 8 week Sales = CALCULATE(SUM(Sales[Net Sales]),FILTER(all('Date'),'Date'[Week Rank]>=min('Date'[Week Rank])-8 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
or
Next 8 Week Sales =
Var _min = maxx(allselected('Date','Date'[Week Rank])
Var _max = maxx(allselected('Date','Date'[Week Rank]) -8
CALCULATE(SUM(Sales[Net Sales]),FILTER(all('Date'),'Date'[Week Rank]>=_min && 'Date'[Week Rank]<=_max))

 

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Jaf017 , Refer my blog for that

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Rolling 8 week Sales = CALCULATE(SUM(Sales[Net Sales]),FILTER(all('Date'),'Date'[Week Rank]>=min('Date'[Week Rank])-8 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
or
Next 8 Week Sales =
Var _min = maxx(allselected('Date','Date'[Week Rank])
Var _max = maxx(allselected('Date','Date'[Week Rank]) -8
CALCULATE(SUM(Sales[Net Sales]),FILTER(all('Date'),'Date'[Week Rank]>=_min && 'Date'[Week Rank]<=_max))

 

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.