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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
thomasAL
Frequent Visitor

Calculate price difference between 2 locations for a selected maturity - Need help please

Dear Community,

I am desperately trying to calculate the difference of price 'ProductValue' (from the Fact table) between 2 hub locations on a matrix visual. Basically I want to perform a A - B calculation with knowing that A is the based price (base in Germany "DE") and B represents a chosen hub location chosen from the '_dlv Zone-Hub' column in Dim Table. I want also to choose a specific maturity "Y+1-BL" or "Y+2-BL", etc, ... To picture the above described, here is what I am trying to operate:

A-B 2.png

I have tried to create a mnew measure with this DAX statement but it's not working: 

DIFF =
CALCULATE(
SUM('Fact TblMarketPrice'[ProductValue]),
FILTER('Dim TblMarketProduct','Dim TblMarketProduct'[_Mat T ST] = SELECTEDVALUE('Dim TblMarketProduct'[_Mat T ST])
),
FILTER('Dim TblMarketProduct','Dim TblMarketProduct'[_dlv Zone-Hub] = "DE")
) -
CALCULATE(
SUM('Fact TblMarketPrice'[ProductValue]),
FILTER('Dim TblMarketProduct','Dim TblMarketProduct'[_Mat T ST] = SELECTEDVALUE('Dim TblMarketProduct'[_Mat T ST])
),
FILTER('Dim TblMarketProduct','Dim TblMarketProduct'[_dlv Zone-Hub] = SELECTEDVALUE('Dim TblMarketProduct'[_dlv Zone-Hub]))
)
 
Can someone help me please? Thanks a lot!
 
Rgds,
Tom
3 REPLIES 3
thomasAL
Frequent Visitor

What if I use one slicer only to choose the maturity "Y+1-BL" or "Y+2-BL" or"Y+3-BL" etc. The thing is that I know this is a row based calculation and it's very unconventional to computerize such logic. I can maybe create a new table and pivot it to obtain my hub locations values as columns, what do you think?

Hi @thomasAL has this problem been solved? Adding a new independent table for hub location and using it in the slicer should be a good idea. Or if it hasn't been solved, can you please share some sample data and the relationships between tables so that we can test it further? Thanks.

 

Best Regards,
Community Support Team _ Jing Zhang

amitchandak
Super User
Super User

@thomasAL , If you need two slicers, one of them needs to be an independent table. You need two tables one will not work. You need to use selectedvalues only for independent table

 

I have a blog, where I have did the same thing on dates. Refer if that can help

https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.