Sub topic 1
Row Context: Evaluating an Expression One Row at a Time
Prerequisites
You should know basic DAX measures, tables, columns, relationships, and filter context. You should also understand fact and dimension tables in a star schema.
Row Context
Row context is the current row while DAX evaluates an expression. An iterator creates row context by visiting a table one row at a time.
For example, a Sales table might contain Quantity and Net Price. The expression below calculates a value for each current row:
Sales[Quantity] * Sales[Net Price]A regular measure does not automatically create this row-by-row evaluation. That is why SUM ( Sales[Quantity] * Sales[Net Price] ) is invalid: SUM accepts one column, not an expression involving multiple columns.
Filter Context
Filter context is the set of filters that determines which rows a measure can see. Filters can come from visual fields, slicers, relationships, or DAX functions such as CALCULATE.
For example, a report filtered to 2026 and the Online channel gives [Sales Amount] only the sales rows that match those filters. An iterator respects this existing filter context unless its table expression changes it.
How Iterators Work
An iterator follows three steps:
- Evaluate a table expression to find the rows to visit.
- Evaluate an expression for each row.
- Combine the results using a function such as
SUMXorAVERAGEX.
The table argument can be a physical table or an expression such as FILTER, VALUES, or ALL. This choice controls the iterator's working set.
SUMX: Summing a Per-Row Calculation
SUMX evaluates an expression for every row and adds the results:
Sales Amount =
SUMX (
Sales,
Sales[Quantity] * Sales[Net Price]
)This is different from SUM ( Sales[Sales Amount] ), which adds an existing column. Use SUMX when the value must be calculated from one or more columns for each row.
Exercise
What does SUMX add in the measure above?
Show answer
It adds each sales row's quantity multiplied by that row's net price.