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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX: How To Sum Multiple Groupings of Absolute Values

DateVal1Val2DifferenceAbsolute Value Difference
1/1/201806-66
1/2/20186511
1/3/20187255
Total1813012

 

How do I write a DAX Formula to get 12 (The Absolute Value Difference SUMMED BY DAYS) as my desired output instead of 0?

 

This is the calculation and result I am getting currently: 

ABS(Sum(Val1)) - ABS(Sum(Val2)) = 0

1 ACCEPTED SOLUTION

Use ABS only once, after subtracting the two sums

 

...

CALCULATE(

                          ABS( SUM('auditModelMessageCount'[Axeda ABC]) - SUM('auditModelMessageCount'[Raw Message History]) )

) ...

View solution in original post

5 REPLIES 5
MattAllington
Community Champion
Community Champion

It depends on your table structure and you have t said if you have one or more tables. Assuming one table, this should work

 

SUMX(VALUES(table[Date]),CALCULATE(abs(sum(val1))-abs(sum(val2))))

 

you can learn about sum vs sumx in power BI at this link. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

Matt, 

 

Thanks for the quick response. My result is still 0 with that formula (see below in context). To answer question about data structure.... all my columns are from 1 table like you correctly assummed from the example above.

 

Test1 = SUMX(

                   VALUES('auditModelMessageCount'[auditDate]),

                        CALCULATE(

                          ABS(SUM('auditModelMessageCount'[Axeda ABC])) - ABS(SUM('auditModelMessageCount'[Raw Message History]))

                                          )

                       )

Use ABS only once, after subtracting the two sums

 

...

CALCULATE(

                          ABS( SUM('auditModelMessageCount'[Axeda ABC]) - SUM('auditModelMessageCount'[Raw Message History]) )

) ...

Anonymous
Not applicable

THANK YOU! THAT WORKS!

 

Test1 = SUMX(
                  VALUES('auditModelMessageCount'[auditDate]),
                            CALCULATE(

                                     ABS(

                                          SUM('auditModelMessageCount'[Axeda ABC]) - SUM('auditModelMessageCount'[Raw Message History])

                                          )

                                              )
                        )

Yeah, I just copied the OP formula and assumed there was some reason it was that way.  Obviously not 🙂



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.