SUM adds up a column. SUMX does something more flexible: it goes through a table row by row, calculates an expression for each row, and then adds the results. That is the key difference between simple aggregation and iteration in DAX.
SUM vs SUMX
Total Sales = SUM(Sales[Amount]) adds the Amount column.
Total Revenue = SUMX(Sales, Sales[Quantity] * Sales[Price]) multiplies quantity by price on each row, then adds the results. A plain SUM cannot do this, because the multiplication has to happen per row first.
Row context
Inside SUMX, DAX evaluates the expression in row context: for each row, it knows the current row’s values. This is different from filter context, which comes from slicers and visuals. Understanding both is the core of DAX.
A common pattern: calculate a value per product
Gross Margin = SUMX(Sales, Sales[Quantity] * (Sales[Price] - RELATED(Products[Cost])))
RELATED follows a many-to-one relationship from the sales table to the products table, so each sales row can read the product’s cost.
Other iterators
AVERAGEX: an average of row-level results, such as average revenue per order line.MAXXandMINX: the largest or smallest row-level value.COUNTX: counts rows where an expression returns a value.FILTER: returns a table of rows matching a condition, often used inside CALCULATE.
Performance
Iterators run over every row, so they are slower on very large tables. Use a plain SUM or a measure built on a simple column whenever possible, and reserve SUMX for calculations that genuinely need row-level logic.
Common mistakes
- Using SUM on a column that needs multiplying first, which gives silently wrong totals.
- Forgetting that RELATED only works along a relationship that exists in the model.
- Nesting iterators unnecessarily; check whether a simpler measure gives the same result.
Related: DAX CALCULATE explained, DAX basics: measures vs calculated columns and Power BI time intelligence.
Power BI and DAX are taught with projects in our 5-month Data Analytics course in Bangalore.
Book a free demo class at our BTM Layout centre, and ask a counsellor for batch details.
