Understand DAX context in Power BI: row context, filter context, and CALCULATE
DAX (Data Analysis Expressions) defines calculations over columns and tables in a Power BI semantic model. When a result surprises you, inspect which rows and filters the expression can see. Row context identifies the row currently being evaluated; filter context defines the data included. CALCULATE changes filter context and can perform context transition when an aggregate is evaluated from a row context.
Understand DAX context in Power BI: row context, filter context, and CALCULATE
DAX (Data Analysis Expressions) defines calculations over columns and tables in a Power BI semantic model. When a result surprises you, inspect which rows and filters the expression can see. Row context identifies the row currently being evaluated; filter context defines the data included. CALCULATE changes filter context and can perform context transition when an aggregate is evaluated from a row context.
Where the calculation runs
DAX uses model columns and relationships rather than Excel-style cell ranges. A model measure is evaluated for a report cell’s filters; a calculated column stores a value per row at refresh. Power Query M prepares and transforms data, while DAX defines analytical calculations over the model. Microsoft: DAX basics · Microsoft: DAX overview
Filter context
Filter context is the set of values a calculation may include. A year slicer, product category, or visual row applies conditions to each cell. Relationships propagate filters according to their direction. Therefore one measure can return different values for all of 2026 and for bikes in 2026.
Assume the model has Sales[Amount], Product[Color], and Product[Category]. Define a base measure:
Sales Amount = SUM ( Sales[Amount] )Putting Category on rows gives each cell a category filter. CALCULATE can add a color condition:
Blue Sales = CALCULATE ( [Sales Amount], Product[Color] = "Blue" )CALCULATE evaluates the measure under modified filter context. By default, a filter argument replaces an existing filter on the same column; filters on other columns remain. Thus this selects Blue even if a Color slicer selects Red. Use KEEPFILTERS if you want the intersection. Verify that replacement is intended. Microsoft: CALCULATE · Microsoft: KEEPFILTERS
Microsoft also documents that CALCULATE and KEEPFILTERS aren't supported in DirectQuery models when used in calculated columns or RLS rules. Check both where the expression runs and the table's storage mode. Microsoft: CALCULATE · Microsoft: KEEPFILTERS
Row context
A calculated column is evaluated for each row and has row context. Iterator functions such as SUMX also evaluate an expression one row at a time. This example multiplies quantity by unit price for each sales row and then sums the results:
Sales Amount by Line = SUMX ( Sales, Sales[Quantity] * Sales[UnitPrice] )The first argument is the table to iterate; the second is evaluated per row. This differs from multiplying the sum of quantities by the sum of unit prices. Row context alone does not automatically filter every related table; a suitable relationship and a function such as RELATED may be needed.
Context transition
Row context alone does not automatically restrict an aggregate from another table to the current row’s key. CALCULATE can turn current row values into filter context even without a filter argument. This is context transition. A calculated column on Product can calculate sales for each product with:
Product Sales = CALCULATE ( [Sales Amount] )The current Product row becomes a filter, and the relationship limits Sales to that product. Referencing a model measure from row context performs context transition automatically. Keep this in mind when calling a measure inside an iterator. For a raw aggregation expression, decide whether CALCULATE is needed. Calculated columns on large tables also cost storage and processing. Microsoft: CALCULATE context transition
Trace context with small numbers
Illustrative data: product A sells 2 units at 10 each; product B sells 1 at 30. Product filters many Sales rows.
| Product | Quantity | Unit price | Line amount |
|---|---|---|---|
| A | 2 | 10 | 20 |
| B | 1 | 30 | 30 |
Selecting A makes Sales Amount equal 20 in filter context.
SUMX evaluates 20 and 30 in row context, then sums rows permitted by current filters.
In Product, CALCULATE([Sales Amount]) converts the current row into a filter: 20 for A and 30 for B.
Blue Sales preserves Category but sets Color to Blue, replacing a prior Color filter by default.
These are constructed teaching values, not results from a tested Power BI environment. Missing keys, bidirectional or inactive relationships, and duplicate keys can change real results.
Debug an unexpected result
Identify whether the calculation is a measure, calculated column, or iterator expression.
List slicer, visual, page, and CALCULATE filters.
Check active relationships, cardinality, filter direction, and duplicate keys.
Locate row context: the calculated row or table scanned by SUMX.
Decide whether CALCULATE should replace a filter or intersect with it.
Inspect intermediate results with simple measures.
If needed, inspect the visual’s DAX query. Performance Analyzer can help open it in DAX Query View; interface details vary by release. [Microsoft: DAX Query View](https://learn.microsoft.com/en-us/power-bi/transform-model/dax-query-view)
Filter context determines what data a measure sees; row context identifies a current row; context transition turns row values into filters. Before rewriting DAX, draw the contexts and relationship paths.