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
Anonymous
Not applicable

Running Totals with sales table dates and date table dates

Hello,

 

I'm trying to write some fixed time period Running Total measures (e.g. 90-Day Revenue) and have had some issues stemming from having a date table that runs out a couple of years in front of the sales table.

 

I'm using this pattern to limit the dates to when I have sales:

90-Day Sales =

CALCULATE(

[Sales],

DATESINPERIOD(Date_Table[Date], MAXX(Sales_Table, Sales_Table[Date],

-90,

DAY)

When the filter context is my whole company, this measure works fine.  Here is a typical visualization of one of these measures (running 90-Day Distribution by Week Ending):

benlewellyn_0-1609774197976.png

 

However, when the filter context includes specific items or territories, the MAXX(Sales_Table, Sales_Table[Date]) will refer to different dates for each row, throwing off totals.

benlewellyn_1-1609774540774.png

I want to refer to dates no later than the last day of sales, and then I want to see the last 90 days of sales for each row from that date (not from the individual row's last sales date).

 

Thanks for your help,

Ben

 

2 REPLIES 2
Anonymous
Not applicable

Hi @amitchandak , isn't that the syntax I am already using?  Not sure what I've left out.

 

Thanks,

Ben

amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

CALCULATE([Sales],DATESINPERIOD(Date_Table[Date], MAXX(Sales_Table, Sales_Table[Date]),-90,DAY))

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.