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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
mwmchugh215
Frequent Visitor

Sum for most recent date available

I have a table that records sales by date. I need to be able to display the total sales for each date and also display the prior date's total. What is a measure in dax that I can use to sum based on whatever the next most recent date is?

 

I tried doing a RANKX column on the record dates, which works correctly in providing a numbered rankings for date, then used the below:

Prior Date Sales =
CALCULATE(SUM(RecordDate[Sales], RecordDate[RankNo] = RecordDate[RankNo]-1)
 

However when I use this measure in a table with the date and total sales, the Prior Date Sales is blank.

 

Is there anything I'm missing with this measure?

 

Sample of data and the result I'm trying to accomplish:

Table: 

Record DateSales
5/13/2024100
5/9/2024200
5/9/2024200
5/2/2024300
5/2/2024300
4/28/2024400
4/28/2024100

 

 Totals: 

Record DateTotal SalesPrior Date Sales
5/13/2024100400
5/9/2024400600
5/2/2024600500
4/28/2024500 
6 REPLIES 6
v-yaningy-msft
Community Support
Community Support

Hi, @mwmchugh215 

Thanks for @smpa01 reply. Have you resolved your issue now, happy to help, have you checked that your data types are as expected, or can you share the pbix file with no sensitive data so it's quicker to determine why your data is not showing up.


Best Regards,
Yang
Community Support Team



Hi though this solution did not work for me I was able to resolve on my own.

Hi, @mwmchugh215 

Glad you solved the problem, if you don't mind could you attach your solution so that someone with a similar problem can find the solution, thanks in advance!

Best Regards,
Yang
Community Support Team

smpa01
Super User
Super User

@mwmchugh215  you can do this

smpa01_0-1715628573324.png

 

smpa01_1-1715628587529.png

 

Prior Sales = CALCULATE([Total Sales], OFFSET(-1,ALL(data[Record Date]),ORDERBY(data[Record Date])))

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

I was able to create the measure with no errors however still getting blank values in the table. I'll receive a total value for prior date when I add in total sales for that date as a column value. But the prior date values for each is still blank.

 

mwmchugh215_0-1715629616518.png

 

@mwmchugh215  I tried to answer as per your sample data and desired output provided previously as you can see in the screenshot. I am not sure what you are referring to. please provide sample data and exact desired output.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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