By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Iterators in Power BI (like SUMX, AVERAGEX, RANKX, and CONCATENATEX) are row-by-row calculation engines that let you perform complex aggregations, rankings, and text manipulations without writing SQL or Python. They’re the secret sauce behind dynamic measures, custom rankings, and conditional aggregations in real-world dashboards.
SUMX
AVERAGEX
RANKX
CONCATENATEX
Why this matters in production:- Without iterators, you’re stuck with basic SUM() and AVERAGE(), which fail when you need weighted averages, conditional sums, or row-level logic (e.g., "Sum sales only for products with >100 units sold").- With iterators, you can: - Calculate profit margins per product (SUMX(Products, [Revenue] - [Cost])). - Rank top customers by spend (RANKX(ALL(Customers), [Total Sales])). - Concatenate all product names in a category (CONCATENATEX(Products, [ProductName], ", ")).- Real-world scenario: You inherit a Power BI report where a measure like "Total Revenue" is hardcoded to sum all sales, but the business now wants "Revenue from High-Margin Products Only". Without iterators, you’d need to rewrite the entire data model. With SUMX, you just add a filter inside the measure.
SUM()
AVERAGE()
SUMX(Products, [Revenue] - [Cost])
RANKX(ALL(Customers), [Total Sales])
CONCATENATEX(Products, [ProductName], ", ")
"Total Revenue"
CALCULATE(SUM(), FILTER())
ALL()
ALLEXCEPT()
SUM
AVERAGE
SUMX(Products, SUMX(Stores, [Sales]))
CALCULATE
EARLIER
ProductID
ProductName
Category
SalesAmount
Cost
Goal: Sum revenue only for products where profit margin > 30%.
SUM([SalesAmount])
(SalesAmount - Cost) / SalesAmount > 0.3
HighMarginRevenue = SUMX( Sales, // Table to iterate over IF( (Sales[SalesAmount] - Sales[Cost]) / Sales[SalesAmount] > 0.3, Sales[SalesAmount], // Include in sum if margin > 30% 0 // Exclude otherwise ) )
[HighMarginRevenue]
ProfitMargin
dax HighMarginRevenue_Optimized = CALCULATE( SUM(Sales[SalesAmount]), Sales[ProfitMargin] > 0.3 )
SUMX(FILTER(Sales, Sales[Region] = "West"), ...)
VAR
dax HighMarginRevenue = VAR MinMargin = 0.3 RETURN SUMX( Sales, IF(([SalesAmount] - [Cost]) / [SalesAmount] > MinMargin, [SalesAmount], 0) )
SUMMARIZE
GROUPBY
dax TotalSalesByCategory = SUMX( SUMMARIZE(Sales, Sales[Category], "CategorySales", SUM(Sales[SalesAmount])), [CategorySales] )
HighMarginRevenue
Measure1
RANKX(ALL(Table), [Measure])
Trap: AVERAGE ignores row-level logic.
"How do you rank customers by sales, ignoring filters?"
Trap: Forgetting ALL() causes rankings to change with slicers.
"What’s the difference between SUMX and CALCULATE(SUM())?"
CALCULATE(SUM())
ALL
", "
Create a measure that concatenates all product names in a category, separated by commas.Example output: "Laptop, Monitor, Keyboard".
"Laptop, Monitor, Keyboard"
ProductsInCategory = CONCATENATEX( VALUES(Products[ProductName]), // Table to iterate over Products[ProductName], // Column to concatenate ", " // Delimiter )
Why it works:- VALUES(Products[ProductName]) removes duplicates (use DISTINCT if needed).- CONCATENATEX joins the values with the specified delimiter.
VALUES(Products[ProductName])
DISTINCT
SUMX(Table, Expression)
AVERAGEX(Table, Expression)
BLANK()
RANKX(Table, Expression, [Value], [Order], [Ties])
CONCATENATEX(Table, Column, Delimiter)
EARLIER(Column, [Number])
Iterators are powerful but expensive. Always ask: - "Can I pre-aggregate this in Power Query?" - "Do I need row-level logic, or can I use CALCULATE?"
Now go build something awesome. ?
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.