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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Previous Period Average Based On Date Range Selection

Hi Everyone, 

 

I'm a bit stuck on something. I'm trying to find previous period average sales. This on its own i've been able to do, however, where i'm getting stuck is i need to find average sales for the [date range selected on slicer] minus 7 days. 

 

For example: 

If i select date range as 25/09/20 - 30/09/20, then the 'previous period' would be 18/09/20 - 24/09/20. So it's the min date of what the user selects minus 7 days. 

 

I tried that logic but i think i'm using the incorrect functions because i keep getting errors. 

 

Is anyone able to shed some light on what approach i need to take? 

 

Thanks guys!

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

You can also take a look at the following blog to use the date function to manually define the filter range to calculate the rolling average:

Time Intelligence "The Hard Way" (TITHW)  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , Try a trailing 7 days measure. But use date table with that

 

Trailing 7 days =CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-7,DAY))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hi @amitchandak - I keep getting the same average as the time period selected, rather than the average for the previous period. This is what i'm using: 

 

var average = SUMMARIZE('FactSales', 'Date'[Date], "AverageAmount", SUM('FactSales'[SalesValue])), [AverageAmount])

   return 
      CALCULATE(_average, DATEADD('Date'[Date], -7, DAY))
 
 

@Anonymous , try like

 

CALCULATE(SUM('FactSales'[SalesValue]), DATEADD('Date'[Date], -7, DAY))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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