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
Anonymous
Not applicable

Generate Spread between Slicer Selected Values: Calculations operate on both lines seperately

I have two measures created which correctly pull the two selected columns individually, which are as follows:
 
Filter First Security =
CALCULATE(
Sum('First Data'[Value]),
Filter(
Rates,
Rates[Security] IN {SELECTEDVALUE('Second Selection'[Security])}))
 
Filter Second Security =
CALCULATE(
Sum('First Data'[Value]),
FILTER(
Rates,
Rates[Security] IN {SELECTEDVALUE('First Selection'[Security])}))

I've got a third measure, which is meant to find the difference between the values of the two measures, but for some reason, it keeps generating the two above measures seperately, with the subtract operation just giving an inverted line. That measure is as follows:
 
Calculated Spread =
CALCULATE(
(value([Filter First Security])-Value([Filter Second Security])),
Filter('First Data', [Value]))
 
Heres a photo of the dashboard, as well, if that helps to understand what im trying to output. 
SAckley_0-1638978606381.png

 

Thanks for any help you all can gather!



1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

Calculated Spread =[Filter First Security])-[Filter Second Security])

 

If the above measure doesn't work, you can try formula as below:

 

Calculated Spread =
VAR tab =
    SUMMARIZE (
        'First Data',
        'First Data'[Date],
        //'First Data'[Security],
        "measure1", [Filter First Security],
        "measure2", [Filter Second Security]
    )
RETURN
    SUMX ( tab, [measure1] - [measure2] )

 

If it doesn't work, please share a sample file for further research.

Best Regards,
Community Support Team _ Eason

 

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

Can you tell me if your problem is solved?

If it doesn't work, please a sample file for further research.

 

Best Regards,
Community Support Team _ Eason

ValtteriN
Super User
Super User

Hi,

Typically difference measures should work simpy by subtracting the first measue from the second one. So a simple Calculate spread = [Filter First Security]-[Filter Second Security]. Is there a reason this doesn't work in your example?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thats what i thought as well, so you see my confusion. The measures are just filtering for the selected values, so i wouldnt think that would cause an issue, but it seems to want to register them seperately as opposed to combining them. I could try removing the calculate function and see if thats the issue, but otherwise, im lost as to why it doesnt want to simply subtract the values

Hi, @Anonymous 

 

Calculated Spread =[Filter First Security])-[Filter Second Security])

 

If the above measure doesn't work, you can try formula as below:

 

Calculated Spread =
VAR tab =
    SUMMARIZE (
        'First Data',
        'First Data'[Date],
        //'First Data'[Security],
        "measure1", [Filter First Security],
        "measure2", [Filter Second Security]
    )
RETURN
    SUMX ( tab, [measure1] - [measure2] )

 

If it doesn't work, please share a sample file for further research.

Best Regards,
Community Support Team _ Eason

 

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.

Top Solution Authors