Row Context vs Filter Context
Power BI · DAX (Data Analysis Expressions)
Theory
DAX evaluates every expression inside an evaluation context, and there are two kinds. Row context means 'the current row': it exists in calculated columns and inside iterators such as SUMX, so an expression like Sales[Qty] * Sales[Amount] can read the values of that one row. Row context does not filter other tables or rows by itself.
Filter context is the set of filters active when a measure is evaluated: the row and column headers of the visual, slicers, page and report filters, and filters added by CALCULATE. For the cell 'North' in a table visual, the filter context is Region = North, so SUM(Sales[Amount]) sees only North's three rows and returns ₹3,200. A common mistake is writing SUM(Sales[Amount]) in a calculated column and expecting a per-row value: there is no filter context per row, so every row gets the grand total, ₹6,200, unless context transition is used.
Why we use it
These two contexts explain almost every 'why is my DAX wrong?' question. Once you know which context you are in, results stop being surprising.
When to use it
Think row context when writing calculated columns and iterator expressions; think filter context when writing measures for visuals. Use CALCULATE when you need to change the filter context or turn row context into filter context.
How it works
- DAX expression is evaluated
- Is there a current row (column or iterator)? Yes: Column references read that row's values. No: Column references need an aggregation.
- Apply the filter context from visual, slicers and CALCULATE
- Aggregate the visible rows
- Return the value
Syntax
Row context: created by calculated columns and iterators (SUMX, AVERAGEX, FILTER, ADDCOLUMNS…)
Sales[Line] = Sales[Qty] * RELATED(Products[Price])
Filter context: created by visuals, slicers, filters and CALCULATE
Total Sales = SUM(Sales[Amount])Example
// Row context: one value per Sales row (calculated column)
Unit Price = DIVIDE(Sales[Amount], Sales[Qty]) // 101 → 600, 103 → 500
// Filter context: one value per visual cell (measure)
Total Sales = SUM(Sales[Amount]) // North → 3,200
// Pitfall: calculated column Bad Total = SUM(Sales[Amount]) → 6,200 on every rowKey points
- Row context = current row; filter context = active filters
- Calculated columns and iterators create row context
- Visuals, slicers and CALCULATE create filter context
- Row context does not filter automatically
- CALCULATE converts row context into filter context (context transition)