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
JamesBowdidge
Frequent Visitor

Last 7 days average revenue

Hi,

 

This must be simple but its beaten me.. All I need is a measure to calulate just the last 7 days average revenue..

 

Table is below, each line is a sale on the date specified.

 

All I want is the average daily total for the last 7 days.. so totaling all sales from yesterday, back 7 days and providing the average..

 

thanks

 

JamesBowdidge_0-1666361170556.png

 

1 ACCEPTED SOLUTION

@JamesBowdidge OK, how about:

Measure = 
  VAR __Date = MAX('Table'[Booked Date])
  VAR __MaxDate = __Date - 1
  VAR __MinDate = __MaxDate - 7
  VAR __Table = SUMMARIZE(FILTER(ALL('Table'),[Booked Date] >= __MinDate && [Booked Date] <= __MaxDate),[Booked Date],"__LRev",SUM('Table'[LRev]))
RETURN
  AVERAGEX(__Table,[__LRev])

@ 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

5 REPLIES 5
JamesBowdidge
Frequent Visitor

Greg_Deckler
Super User
Super User

@JamesBowdidge Try:

Measure = 
  VAR __Date = MAX('Table'[Booked Date])
  VAR __MaxDate = __Date - 1
  VAR __MinDate = __MaxDate - 7
RETURN
  AVERAGEX(FILTER(ALL('Table'),[Booked Date] >= __MinDate && [Booked Date] <= __MaxDate),[LRev])

@ 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...

Hi Mate, contrary to saying its the solution (hit the wrong button)

 

Your formular seems to be averaging the last 7 records (and returns 62.90, rather then the expected 170,000 ish)..

I need the sum of each of the 7 days sales, and then average those numbers.. 

 

thanks for your help!

@JamesBowdidge OK, how about:

Measure = 
  VAR __Date = MAX('Table'[Booked Date])
  VAR __MaxDate = __Date - 1
  VAR __MinDate = __MaxDate - 7
  VAR __Table = SUMMARIZE(FILTER(ALL('Table'),[Booked Date] >= __MinDate && [Booked Date] <= __MaxDate),[Booked Date],"__LRev",SUM('Table'[LRev]))
RETURN
  AVERAGEX(__Table,[__LRev])

@ 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...

@Greg_Deckler 

 

perfect, that got it! accepted as solution.. thanks so much!

 

DAX is very new to me.. hopeing it wont take long to pick it up!! 

 

thanks once again for your help!

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.