One of the most fundamental — yet confusing — concepts in DAX is context. Understanding how Row Context, Filter Context, and Query Context work is the key to writing accurate, powerful, and optimized DAX formulas.
In this blog, we’ll break down each context type, provide clear real-world examples, and explore how they interact in Power BI.
What is “Context” in DAX?
In DAX, context determines how a formula is evaluated. Think of it as the environment or conditions under which a calculation is performed.
There are three primary types of context:
- Row Context
- Filter Context
- Query Context
Each plays a different role in how data is calculated, filtered, and displayed.
1. Row Context
What it is:
Row context exists when DAX evaluates a single row at a time, usually in calculated columns or iterating functions like SUMX, FILTER, ADD COLUMNS, etc.
Example: Calculated Column
Assume you have a table called Sales:

You create a calculated column:

Here, for each row, DAX automatically applies row context — it knows which row’s Quantity and Unit Price to use.
Key point:
Row context means “I’m looking at this row only.”


Filter Context
What it is:
Filter context comes from report filters, slicers, visuals, or explicitly in a DAX formula via CALCULATE, FILTER, etc.
It tells DAX which subset of data to consider before performing a calculation.
Example: Measure
Let’s define a measure:

Now in a visual with a slicer for Product = “A”, the measure only considers rows where Product = “A” — this is filter context in action.
Advanced: Use of CALCULATE to Modify Filter Context
Here, CALCULATE creates a new filter context, overriding any existing one from visuals.

Key point:
Filter context answers “What subset of data should I use?”


Query Context
What it is:
Query context is the context generated by the visual or report — it determines what is being asked by a matrix, chart, or table.
Example: Visual Table
You drop a matrix visual with Product on rows and [Total Sales] as values.
Power BI internally generates queries like:

For each Product, DAX applies the query context, and this in turn triggers the filter context during the measure calculation.
Key point:
Query context sets the outer structure, filter context sets the data subset, and row context operates inside formulas.

Context Transition: Where It Gets Interesting
Context Transition = Row → Filter
This happens when a row context (like from FILTER() or an iterator) is converted to a filter context — usually via CALCULATE.
Example:

If this is used inside a row-level iterator like SUMX, each row context is converted to a filter context so that SUM works correctly.
Without CALCULATE, the measure wouldn’t behave as expected inside a row-wise iteration.
Real-World Scenario: Misunderstanding Context
Imagine this:

If [Total Sales] is a measure, it will use filter context, not row context. So you’re calculating the same total over and over.
Instead, use:

Or convert [Total Sales] to a calculated column if that’s what you really want.
Summary Table:

Final Thoughts:
Mastering DAX context is like learning the grammar of a new language — once you understand the structure, writing powerful expressions becomes natural.
Always ask yourself:
- What row(s) am I looking at? (Row context)
- What filters are applied? (Filter context)
- What is the visual asking for? (Query context)
If you’re getting unexpected results in a measure, you’re probably fighting the wrong context.