Short answer: SUM ( Sales[Amount] ) adds up one column. SUMX ( table, expression ) goes through a table row by row, evaluates the expression for each row, and adds the results. Use SUM when the number is already in a column. Use SUMX when it must be calculated per row first (Quantity * Price), or when a total must add up the rows of a visual (the sum of per-customer results). Internally, SUM ( col ) is SUMX ( table, col ), so there is no speed penalty for SUMX with simple column math.
A Sales table has Quantity and Unit Price but no Amount. SUM ( Sales[Quantity] ) * SUM ( Sales[Unit Price] ) multiplies two totals and is badly wrong. SUMX ( Sales, Sales[Quantity] * Sales[Unit Price] ) multiplies per line, then adds.
Why does the order of operations matter?
| Line | Quantity | Unit Price | Quantity x Price |
|---|---|---|---|
| 1 | 2 | 10 | 20 |
| 2 | 5 | 100 | 500 |
| SUM(Qty) x SUM(Price) | 7 | 110 | 770 |
| SUMX(Qty x Price) | 520 |
Revenue Wrong = SUM ( Sales[Quantity] ) * SUM ( Sales[Unit Price] )
Revenue = SUMX ( Sales, Sales[Quantity] * Sales[Unit Price] )When else do you need SUMX?
-- 1 a related value per row
Revenue at List = SUMX ( Sales, Sales[Quantity] * RELATED ( 'Product'[List Price] ) )
-- 2 a weighted average: price weighted by quantity
Avg Price Weighted =
DIVIDE ( SUMX ( Sales, Sales[Quantity] * Sales[Unit Price] ), SUM ( Sales[Quantity] ) )
-- 3 a total that adds up the rows: sum of each customer's capped bonus
Bonus =
SUMX (
VALUES ( Customer[Customer] ),
MIN ( [Revenue] * 0.05, 500 )
)
-- 4 currency conversion per row
Revenue EUR = SUMX ( Sales, Sales[Amount] * RELATED ( Rates[Rate] ) )Example 3 is the important one for totals. Without SUMX, the total row computes MIN ( total revenue * 0.05, 500 ), which is 500, not the sum of the customers' bonuses.
Why do totals not add up without it?
| Customer | Revenue | Bonus with MIN only | Bonus with SUMX over customers |
|---|---|---|---|
| Ana | 4,000 | 200 | 200 |
| Ben | 20,000 | 500 | 500 |
| Chen | 8,000 | 400 | 400 |
| Total | 32,000 | 500 | |
| Total | 32,000 | 1,100 |
A measure is evaluated in the total's own filter context, not as a sum of the rows. SUMX over the grouping column forces the total to be the sum of the per-row results.
How fast is SUMX?
Simple arithmetic on columns of one table (Quantity * Price) is handled by the storage engine in bulk and is as fast as SUM. It gets slower when:
- the expression calls a measure (one context transition per row): iterate a small table such as
VALUES ( Customer[Customer] ), not the fact table, - the expression uses
RELATEDacross large tables, - the expression has
IFor other logic the storage engine cannot push down.
A calculated column Line Amount makes SUM possible but costs memory; with SUMX the model stays smaller.
What goes wrong?
- Multiplying sums.
SUM ( A ) * SUM ( B )is notSUMX ( A * B ). - SUMX over the fact table with a measure inside. Millions of context transitions; iterate the dimension.
- Expecting SUMX to change filters. It iterates the rows in the current filter context; it removes nothing.
- Blank handling. Rows where the expression is BLANK are skipped in the sum.
Where can you check this?
- Microsoft Learn: SUM function (DAX)
- Microsoft Learn: SUMX function (DAX)
- Microsoft Learn: Aggregation functions (DAX)
Where do you start?
Find measures that multiply two sums or totals that do not match their rows, and rewrite them with SUMX over the right table. AVERAGEX, MINX and MAXX work the same way for other aggregates.