Back to Roadmap
Level 3 — Iterators & X-Functions+75 XP
Lesson 3
3. Iterator vs Aggregation
When to use SUM vs SUMX: Performance and best practices.
The Concept
If the column already exists in the table, use SUM(Table[Column]). If you need row-level math across columns, use SUMX.
Example DAX:
// Fast: uses column storage engine Total Sales = SUM(Sales[Revenue]) // Needed only when multiplying columns or applying row-level math Total Margin = SUMX(Sales, Sales[Revenue] - Sales[Cost])
SUM is optimized by the VertiPaq storage engine and is extremely fast. Don't use SUMX(Sales, Sales[Revenue]) when SUM(Sales[Revenue]) works.
Try It Yourself
Calculate Total Margin using SUMX over Sales subtracting Cost from Revenue.
fx
[fx]Iterator vs Aggregation=
Loading DAX Formula Studio...
Type [ for fields