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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors