Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello Everyone,
I am stuck in creating DAX function to create sales difference between two consecutive dates. I have a data in the following table shown below -
| As_of_Date | Sales |
| 07-05-2025 | 34 |
| 07-05-2025 | 34 |
| 07-05-2025 | 34 |
| 08-05-2025 | 54 |
| 09-05-2025 | 23 |
| 09-05-2025 | 23 |
| 10-05-2025 | 56 |
| 10-05-2025 | 56 |
| 10-05-2025 | 56 |
| 10-05-2025 | 56 |
| 10-05-2025 | 56 |
| 13-05-2025 | 12 |
| 13-05-2025 | 13 |
| 13-05-2025 | 14 |
| 14-05-2025 | 23 |
| 14-05-2025 | 23 |
| 15-05-2025 | 45 |
| 16-05-2025 | 67 |
| 17-05-2025 | 89 |
| 17-05-2025 | 89 |
| 17-05-2025 | 89 |
| 17-05-2025 | 89 |
| 17-05-2025 | 89 |
| 17-05-2025 | 89 |
| 20-05-2025 | 12 |
| 20-05-2025 | 12 |
| 20-05-2025 | 12 |
| 21-05-2025 | 34 |
| 21-05-2025 | 34 |
| 22-05-2025 | 56 |
| 22-05-2025 | 56 |
| 22-05-2025 | 56 |
| 23-05-2025 | 78 |
| 24-05-2025 | 56 |
| 27-05-2025 | 98 |
| 27-05-2025 | 98 |
| 27-05-2025 | 98 |
I need to create a DAX measure to calculate daily total sales and a T-1 sales column to create sales difference between two consecutive days.
Also there is no sales on weekends, so we need to take care of no sales on weekends while calculating the measure - Previous Day Sales
Hi @SC30GSWNBA you can create 2 measures :
PBIX is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
The PreviousDate VAR is returning me 31st Dec 2024. May be that's the reason why it is not working.
Hi @SC30GSWNBA i see that all results are correct....
Did you download the pbix to follow thr steps?
If yes please show what is wrong
Yes, I downloaded your file. I am connected to a database and when I apply MAX(Sales Data[Date]), it gives me 31st Dec 2024 as the output rather than the latest date. Not sure why that is happening.
Unfortunately, I can't determine the exact problem without access to your file.
There's an alternative method to access the value in the row above within a visualization context using the offset function.
Regrettably, I'm currently not at my computer and cannot provide an example. However, you can refer to the guide linked below:
https://youtu.be/C3QY0DWts8w?si=b5JhPQwq51lLw1tO
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.