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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Junaid11
Helper V
Helper V

Difference of sales for each date in Matrix

Hello,
I wanted to create a matrix from below data but it should show the difference for each day. I have attached the outcome as well.
The data is:

Sales numberDateRevenue
A01/01/2020113
B01/01/2020225
C01/01/2020188
A13/01/2020146
B13/01/2020274
C13/01/2020199
A18/01/2020234
B18/01/2020345
C18/01/2020221

The matrix looks like this:

Matrix.PNG

But I want the difference measure/column for each sales number on date sales. I have attached the outcome as well:

Sales Number01/01/2020Difference13/01/2020Difference18/01/2020
A1133314688234
B2254927471345
C1881119922221


Kindly let me know if possible.
Thanks

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Junaid11 here is the updated measure and the file is also attached

 

Prev Visible Day Revenue = 
VAR __transactionDate = MAX ( 'Date'[Date] ) 
VAR __prevVisibleDateRevenue = 
IF ( 
    NOT ISBLANK ( [Total Revenue] ), 
    VAR __prevVisibleDate = CALCULATE ( MAX ( 'Sheet1'[Date] ), 'Date'[Date] < __transactionDate ) 
    RETURN CALCULATE ( [Total Revenue], 'Date'[Date] = __prevVisibleDate ) )
  RETURN __prevVisibleDateRevenue

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



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.

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@Junaid11 here is the updated measure and the file is also attached

 

Prev Visible Day Revenue = 
VAR __transactionDate = MAX ( 'Date'[Date] ) 
VAR __prevVisibleDateRevenue = 
IF ( 
    NOT ISBLANK ( [Total Revenue] ), 
    VAR __prevVisibleDate = CALCULATE ( MAX ( 'Sheet1'[Date] ), 'Date'[Date] < __transactionDate ) 
    RETURN CALCULATE ( [Total Revenue], 'Date'[Date] = __prevVisibleDate ) )
  RETURN __prevVisibleDateRevenue

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



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.

parry2k
Super User
Super User

@Junaid11 I think it is good, you don't have data for each day and the' previous day is getting calculated blank() and giving the wrong diff, we have to tweak it a bit.  Can you send me pbix file with the sample data?



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.

Hello @parry2k ,

Yes the sales/REvenue data would be on different dates not on consecutive. I am attaching link og both the sample file of excel and Pbix. Thanks for you help as well.

https://drive.google.com/file/d/15JubO1Ai_-LIon6qwctZHG3VkeHHJbOX/view?usp=sharing

https://docs.google.com/spreadsheets/d/1ecSAn1F09lnY1RHFBHuDF4uG1pDfBc4F/edit?usp=sharing&ouid=11426...

Junaid11
Helper V
Helper V

Hello @parry2k,

I followed as you have asked but this is what I am getting. Kindly tell me is there any thing that I am doing wrong?

asdasdeee.PNG

parry2k
Super User
Super User

@Junaid11 it is pretty straightforward, first, you add a date dimension in your model, you can follow my blog post to add one Create a basic Date table in your data model for Time Intelligence calculations | PeryTUS IT Solutio...

 

Once you date table and relationship with transaction table, add the following measures:

 

Sales = SUM ( Table[Sales] )

Prev Day Sales = CALCULATE ( [Sales], PREVIOUSDAY ( DateTable[Date] )  )

Diff = [Sales] - [Prev Day Sales]

 

To visualize, use matrix visual, put sales number on rows, date from date table on columns and above measure (sales and Diff) on values and you have the solution

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



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.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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