Row Context vs Filter Context in DAX: Explained with Simple Examples

Row context vs filter context in DAX

If a DAX formula ever gave you a number you could not explain, the cause was almost certainly context. DAX evaluates every formula in a context, and there are two kinds: row context and filter context. Once you understand the difference, CALCULATE, SUMX and most "wrong total" problems suddenly make sense.

Quick answer

  • Row context means "the current row". It exists in calculated columns and inside iterator functions such as SUMX and FILTER. It lets you read a column value from that one row.
  • Filter context means "the set of filters currently applied": slicers, rows and columns of a visual, page filters and CALCULATE filters. Measures are evaluated in filter context.
  • Row context does not filter anything by itself. CALCULATE turns a row context into a filter context (this is called context transition).

The examples use a Sales table (Product, Quantity, Price, Region) and a Product table.

Row context

In a calculated column

Line Amount = Sales[Quantity] * Sales[Price]

Power BI evaluates this once for each row of Sales. For each row, Sales[Quantity] means "the quantity of this row". That is row context.

Inside an iterator

Total Amount = SUMX ( Sales, Sales[Quantity] * Sales[Price] )

SUMX walks through the Sales table row by row, creating a row context for each row, multiplies, then adds the results. Without SUMX, writing Sales[Quantity] * Sales[Price] in a measure fails, because a measure has no current row. More on iterators: SUM vs SUMX.

Filter context

Total Qty = SUM ( Sales[Quantity] )

Put this measure in a table with Region on rows. For the "North" row, the filter context is Region = North, so the measure sums only North rows. Add a Year slicer set to 2026 and the filter context becomes Region = North AND Year = 2026. The same measure gives a different number in every cell because each cell has a different filter context.

The total row has no Region filter, so it sums everything. That is why measures give correct totals automatically, while summing calculated values sometimes does not.

The key point: row context does not filter

Try this calculated column in the Product table:

Product Sales (wrong) = SUM ( Sales[Quantity] )

Every product shows the same number: the grand total. The row context knows which product row you are on, but SUM does not look at row context; it only respects filter context, and there is no filter.

Now wrap it in CALCULATE:

Product Sales = CALCULATE ( SUM ( Sales[Quantity] ) )

Each product now shows its own quantity. CALCULATE takes the current row (this product) and turns it into a filter (Product = this product), which then flows through the relationship to Sales. This is context transition.

Referencing a measure has the same effect, because every measure is automatically wrapped in CALCULATE:

Product Sales = [Total Qty]

Why this matters: three real examples

1. Average sales per customer

Avg Sales per Customer =
AVERAGEX ( VALUES ( Customer[CustomerID] ), [Total Amount] )

AVERAGEX creates a row context for each customer. Because [Total Amount] is a measure, context transition filters Sales to that customer. Without the measure (or CALCULATE), every customer would get the grand total.

2. Count of products with sales above 1,00,000

Big Products =
COUNTROWS (
    FILTER ( VALUES ( Product[Product] ), [Total Amount] > 100000 )
)

FILTER iterates products (row context) and the measure is evaluated per product (context transition).

3. A slow calculated column

Context transition inside a calculated column on a large fact table runs a CALCULATE for every row, which can be slow. If you only need the value in visuals, use a measure instead.

How CALCULATE modifies filter context

North Sales = CALCULATE ( [Total Amount], Sales[Region] = "North" )

CALCULATE replaces any existing filter on Sales[Region] with North, keeping the other filters (such as Year). Functions such as ALL and REMOVEFILTERS remove filters instead. Full guide: CALCULATE in DAX and ALL and ALLEXCEPT.

Summary table

Row contextFilter context
Created byCalculated columns, iterators (SUMX, FILTER, AVERAGEX...)Visuals, slicers, filters, CALCULATE
Meaning"The current row""Which rows are visible"
Filters data?NoYes
Follows relationships?Only with RELATED / RELATEDTABLEYes, automatically
ConvertCALCULATE (or a measure reference) turns row context into filter context

Common mistakes

  • Same value on every row of a calculated column: you aggregated without CALCULATE. Add CALCULATE or reference a measure.
  • "A single value for column cannot be determined": you used a bare column in a measure where there is no row context. Use an aggregation or an iterator.
  • Wrong total row: a measure built from calculated logic per row. See how to fix incorrect totals.

Practice task

Create three columns in the Product table: SUM(Sales[Quantity]), CALCULATE(SUM(Sales[Quantity])) and [Total Qty]. Explain to yourself why the first is different and the other two match. If you can, you understand context.

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Learn Excel, Power BI, and Finance in Simple Hindi and English Follow step-by-step tutorials and practical examples designed for students, job seekers, and working professionals. We cover Power BI dashboards, DAX formulas, Excel tricks, financial literacy, and AI tools.