Iterator Functions — SUMX, AVERAGEX, COUNTX
Use SUMX and other X-functions to calculate row-by-row before aggregating
Iterator functions (SUMX, AVERAGEX, COUNTX, MAXX, MINX) are DAX functions that loop through a table row by row, evaluate an expression for each row, then aggregate the results. They are essential when your calculation involves a row-level formula before summing.
The classic example: Revenue = Quantity × Price. If these are two separate columns, you cannot simply SUM both and multiply — that gives the wrong answer. You need SUMX to multiply row by row, then sum.
Example
Key Points
- ✓SUMX syntax: SUMX(table, expression) — table is iterated, expression is evaluated per row
- ✓SUMX is slower than SUM on large tables — use a calculated column for static row calculations if performance is critical
- ✓The first argument to any X function can be FILTER(table, condition) — "sum only matching rows"
- ✓AVERAGEX gives a different result than AVERAGE when the value is a calculation (not a column)
- ✓Every X function has a non-X equivalent — use X when row-level logic is needed, non-X otherwise
Practice Question
Your Sales table has Quantity and UnitPrice columns. Which formula correctly calculates total revenue (sum of Quantity × UnitPrice per row)?