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

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

Reply
juhoneyighot
Helper III
Helper III

DAX formula to sum amount with negative values

Hello!

 

I hope you could help me with this DAX formula that will be used.

juhoneyighot_0-1720197110402.png

I want to get to sum up all Name with negative amount in Amt Diff (Rev-Cost).

 

Do you know what DAX formula to use?

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @juhoneyighot ,

I create a table as you mentioned.

vyilongmsft_0-1720510010037.png

Then I put it into the matrix visual.

vyilongmsft_1-1720510056138.png

Next I create a measure and get what you want.

Measure = 
VAR _RevCost =
    SUM ( 'Table'[Rev] ) - SUM ( 'Table'[Cost] )
RETURN
    IF ( _RevCost < 0, ( SELECTEDVALUE ( 'Table'[Name] ) ), _RevCost )

vyilongmsft_2-1720510224759.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Poorva_Awale
New Member

Hi All,

Even I am facing similar issue , my data contains both negative and positive values in column 'Revenue', however when i use the same column in my Table visual the negative values are neglected and the table shows only the positive values. I checked that this might be due to the summarization i am doing on the column to get the grand total. How do we handle this, do we have to do any kind of special formatting, etc? 

Anonymous
Not applicable

Hi @juhoneyighot ,

I create a table as you mentioned.

vyilongmsft_0-1720510010037.png

Then I put it into the matrix visual.

vyilongmsft_1-1720510056138.png

Next I create a measure and get what you want.

Measure = 
VAR _RevCost =
    SUM ( 'Table'[Rev] ) - SUM ( 'Table'[Cost] )
RETURN
    IF ( _RevCost < 0, ( SELECTEDVALUE ( 'Table'[Name] ) ), _RevCost )

vyilongmsft_2-1720510224759.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

DataInsights
Super User
Super User

@juhoneyighot,

 

Try this measure:

 

Sum of Negative Amount =
VAR vTable =
    ADDCOLUMNS ( VALUES ( 'Table'[Name] ), "@AmtDiff", [Amt Diff (Rev-Cost)] )
VAR vResult =
    SUMX ( FILTER ( vTable, [@AmtDiff] < 0 ), [@AmtDiff] )
RETURN
    vResult




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

Proud to be a Super User!




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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.