Reply
avatar user
Anonymous
Not applicable

SUMX vs SUM gives different total - why and best practice

I have Raw data [Fiscal Qtr ending] & [Net Revenue]. I am trying to get PBI to return a {Total Net Revenue] "x numbers of days back". SO I use DAX ... Calculate(SUM, DATESINBETWEEN)

 

I started off using Calculate(SUMX , DATESINBETWEEN) - and I notice very small discrepancy (Refer image RED)

However, if I use Calculate(SUM, DATESINBETWEEN) it is correct.. 

 

I dont know if SUMX is the wrong DAX to use - clearly this is the case..

Can you help me understand why? PBI.jpg

1 ACCEPTED SOLUTION

I guess the difference is that with SUM, if you have 100 rows of data, it can do it in a single operation.

 

Whereas with SUMX there will be 100 separate calcuations which then result in a final amount which opens the door for rounding issues????


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

5 REPLIES 5
IK1
New Member

 To understand this you need to understand the functionality of both sum and sumx .if both of them were to give you the same result then why have 2 separate functions at all?

Sumx is iterative in nature and acts row by row.It does the calculation on the table you specify in the argument.For ex : if you write the below syntax

Sumx(financials, Unit_Price*Quantity)

Then sumx will go to the table financials,then for the 1st row multiply Unit_Price*Quantity and simply go to the second row for the same calculation .after all rows are over it does a sum on top of it.

Sum function simply adds up numeric column values and gives you the result in the visual based on other columns you select.

Sum works on a single column while sumx can work on multiple columns.

Found a simple video with indepth explanation that might help you more 

Explanation on sum vs sumx 

 

Thanks for sharing the guy explain very well with examples..!!

Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

That is a very good question and lucky for you there is a very good answer here in this blog post by @MattAllington

 

http://exceleratorbi.com.au/sum-vs-sumx-in-dax/

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

avatar user
Anonymous
Not applicable

Whilst the conclusion here is "Agregate a single column, use SUM".. do we know why in my examples SUMX returned a tiny discrepancy?

 

Thank you Phil

I guess the difference is that with SUM, if you have 100 rows of data, it can do it in a single operation.

 

Whereas with SUMX there will be 100 separate calcuations which then result in a final amount which opens the door for rounding issues????


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)