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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
BabyBinki821
Helper I
Helper I

Trailing 4 Week Average

Hi

 

So I thought I had this solved but i don't 😞 I need 4 week trailing average of the number of orders. Below you can see the graph I am trying to create . The formula below looks like it works but its giving me the current week - 3 previous weeks average. If I change the -3 to -4 I get very different numbers as well.

 

Measure = calculate(AVERAGEX(values('DATE'[Week Rank]),Orders[Total Orders]),filter(all('DATE'),'DATE'[Week Rank]>=max('DATE'[Week Rank])-3 &&'DATE'[Week Rank]<=max('DATE'[Week Rank])))
 
BabyBinki821_0-1649789809228.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@BabyBinki821 , If you do not want this week

 

Measure = calculate(AVERAGEX(values('DATE'[Week Rank]),Orders[Total Orders]),filter(all('DATE'),'DATE'[Week Rank]>=max('DATE'[Week Rank])-4 &&'DATE'[Week Rank]<=max('DATE'[Week Rank])-1  ))

 

or

 

Measure = calculate(AVERAGEX(values('DATE'[Week Rank]),Orders[Total Orders]),filter(all('DATE'),'DATE'[Week Rank]>=max('DATE'[Week Rank])-5 &&'DATE'[Week Rank]<=max('DATE'[Week Rank])-1  ))

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@BabyBinki821 , If you do not want this week

 

Measure = calculate(AVERAGEX(values('DATE'[Week Rank]),Orders[Total Orders]),filter(all('DATE'),'DATE'[Week Rank]>=max('DATE'[Week Rank])-4 &&'DATE'[Week Rank]<=max('DATE'[Week Rank])-1  ))

 

or

 

Measure = calculate(AVERAGEX(values('DATE'[Week Rank]),Orders[Total Orders]),filter(all('DATE'),'DATE'[Week Rank]>=max('DATE'[Week Rank])-5 &&'DATE'[Week Rank]<=max('DATE'[Week Rank])-1  ))

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Thank you!!! It worked!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors