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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Matthew999
New Member

Difference between price of two products for same date

So I was wondering how I would calculate the difference in DAX between two products in my table for the same date so I can see how the price spread changes over time. So my table would look like this: 

DateProductPrice
7/18/2019Corn100
7/18/2019Sugar50
7/17/2019Corn90
7/17/2019Sugar60

And I would like this kind of output: 

 Corn minus Sugar
7/18/201950
7/17/201930

 

Ideally I would also be changing the dates (so maybe only charting the spread evolution over last 6 months) so FILTER incorporation would be ideal. Thanks in advance for any insight on how I could do this!

1 ACCEPTED SOLUTION
Omega
Impactful Individual
Impactful Individual

Assuming you only have two products, try the below measure: 

 

Measure = CALCULATE(SUM('Table'[Price]),'Table'[Product]="Corn") - CALCULATE(SUM('Table'[Price]),'Table'[Product]="Sugar")

View solution in original post

2 REPLIES 2
Omega
Impactful Individual
Impactful Individual

Assuming you only have two products, try the below measure: 

 

Measure = CALCULATE(SUM('Table'[Price]),'Table'[Product]="Corn") - CALCULATE(SUM('Table'[Price]),'Table'[Product]="Sugar")

That works! While there are more than one product, I can just make different measures because each product actually has a lot of other attributes attached (the same product will actually have multiple attributes that I will need to differentiate by like vendor source). Now that I have the framework I will give it a shot. Thanks!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.