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

Subtracting two measures with If condition in dax not showing up a total

In DAX, I am trying to subtract one measure from another , lets say A-B and I wrote a condition (If A>B, A-B, 0). I am not able to get the total of this measure. 

3 REPLIES 3
Anonymous
Not applicable

I am trying to subtract two measures, A-B with a condition that if it is negative value then it should be 0. I am not able to get the total value

v-lili6-msft
Community Support
Community Support

hi, @Anonymous

It is a measure totals problem. Very common. 

here is a post for you to reference:

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

 

IF not your case, Please share some data sample and the formula and expected output. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AkhilAshok
Solution Sage
Solution Sage

If you want the total to work correclty then you should do a SUMX (assuming you looking for sum):

 

Final Measure =
SUMX (
    VALUES ( Table[Dimension Used in your table] ),
    VAR a = [A]
    VAR b = [B]
    RETURN
        IF ( a > b, a - b, 0 )
)

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.