Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
So I have been working on the mentioned subject for past 10 hours straight and I give up. Need your help guys.
I have a table which has data as first table below.
I want a column that subtracts the Current date total sales for each member from previous date and shows the result as 'Today's Sale' for that member.
| Date | Sales Man | Total Sales |
| 04/01/2020 | A | 2 |
| 04/01/2020 | B | 4 |
| 04/01/2020 | C | 6 |
| 04/02/2020 | A | 5 |
| 04/03/2020 | B | 6 |
| 04/03/2020 | C | 10 |
| Date | Sales Man | Total Sales | Today's Sale |
| 04/01/2020 | A | 2 | 2 |
| 04/01/2020 | B | 4 | 4 |
| 04/01/2020 | C | 6 | 6 |
| 04/02/2020 | A | 5 | 3 |
| 04/03/2020 | B | 6 | 2 |
| 04/03/2020 | C | 10 | 4 |
Solved! Go to Solution.
Hi @Anonymous ,
1.Go to query editor> add column> add index column;
2.Create a calculated column to rank the sales man column grouped by sales man:
Column =
RANKX(FILTER('Table','Table'[Sales Man]=EARLIER('Table'[Sales Man])),'Table'[Index],,ASC,Dense)
3.Create a measure as below:
Measure =
var a=CALCULATE(MAX('Table'[Total Sales]),FILTER(ALLSELECTED('Table'),'Table'[Column]=SELECTEDVALUE('Table'[Column])-1&&'Table'[Sales Man]=SELECTEDVALUE('Table'[Sales Man])))+0
Return
MAX('Table'[Total Sales])-a
Finally you will see:
For the related .pbix file,pls click here.
Hi @Anonymous ,
1.Go to query editor> add column> add index column;
2.Create a calculated column to rank the sales man column grouped by sales man:
Column =
RANKX(FILTER('Table','Table'[Sales Man]=EARLIER('Table'[Sales Man])),'Table'[Index],,ASC,Dense)
3.Create a measure as below:
Measure =
var a=CALCULATE(MAX('Table'[Total Sales]),FILTER(ALLSELECTED('Table'),'Table'[Column]=SELECTEDVALUE('Table'[Column])-1&&'Table'[Sales Man]=SELECTEDVALUE('Table'[Sales Man])))+0
Return
MAX('Table'[Total Sales])-a
Finally you will see:
For the related .pbix file,pls click here.
@Anonymous , The above solution from @parry2k will work. You can also try trailing day measure
Diff = SUM ( Table[Sales] ) -CALCULATE (SUM(Table[Sales]), dateadd('Date'[Date],-1,day ))
As mentioned by Parry, To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
@Anonymous try following measure, key here is to add a calendar dimension in your model, set relationship with your sales table with this dimension and mark this dimension as date table. This will make any time intelligence calculation super easy and it is also a best practice.
Prev Day Sales Diff =
SUM ( TableSales[Total Sales] ) -
CALCULATE ( SUM ( TableSales[Total Sales] ), PREVIOUSDAY( 'Calendar'[Date] ) )
Would appreciate Kudos 🙂 if my solution helped.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |