What is Query Context in Power BI?

Cody Schneider••9 min read

Thinking about "context" in Power BI can feel a bit abstract, but it's the secret sauce that makes your reports interactive. This article breaks down exactly what Query Context is, how it relates to Filter and Row Context, and why understanding it is fundamental to building reports that actually work the way you expect.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

First, The Basics: What is Evaluation Context?

Before we can talk about Query Context specifically, we need to understand the larger concept it belongs to: Evaluation Context. In the world of DAX (the formula language for Power BI), nothing is calculated in a vacuum. Every single DAX formula is evaluated in a specific "context."

Think of it like giving directions. If you tell someone to "turn left at the big oak tree," that instruction only makes sense if they know which street they're on and which direction they're facing. That starting point - the street and direction - is their context. Without it, the instruction is useless.

In DAX, the Evaluation Context is the "environment" in which your formula is calculated. It determines which rows of your data tables are visible to the formula at that moment. This context is created by your report's design - the visuals, slicers, rows, and columns you're looking at. There are two primary types of Evaluation Context: Row Context and Filter Context.

The Two Flavors of Context: Filter vs. Row

Understanding the difference between these two is the most important step in mastering DAX. Most confusion and incorrect results come from mixing them up.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

What is Filter Context?

Filter Context is the set of all filters applied to your data model before a measure is calculated. It’s what lets your visuals interact and dynamically update. These filters can come from several places:

  • Slicers and Filters Pane: When a user selects "2023" from a year slicer or applies a filter in the Filters pane, they are creating a Filter Context.
  • Rows and Columns in a Visual: If you have a matrix with product categories as rows, each row ("Electronics," "Clothing," "Home Goods") applies a filter to all the calculations within that row.
  • Other Visuals on the Page (Cross-Filtering): Clicking a bar on a bar chart can filter another visual, like a card or a table. That click also adds to the Filter Context.

Let's use a very simple example. Imagine a Power BI report with a single table visual that shows total sales by country. It looks something like this:

Your DAX measure for Total Sales is simple:

Total Sales = SUM(Sales[SalesAmount])

How does Power BI know to show "$5,000,000" for "USA"? Because of Filter Context. For the first row of the visual, Power BI applies a filter of [Country] = "USA" to the entire data model. Then, it evaluates your Total Sales measure inside that filtered environment. It performs the same process for "Canada," "UK," and so on.

If you add a slicer for "Year" and select "2023", the Filter Context becomes [Country] = "USA" and [Year] = "2023". The Total Sales value updates automatically.

What is Row Context?

Row Context is different. It doesn't filter entire tables, it simply means "the current row I am working on.” It allows you to perform calculations on a row-by-row basis. Row Context exists in two main places:

  1. In a Calculated Column: When you create a new column in one of your data tables using a DAX formula, that formula is evaluated for each row of the table, one at a time. The formula naturally has access to all the values in that specific row.
  2. Inside an Iterator Function: DAX functions ending in "X" (like SUMX, AVERAGEX, FILTER) are called iterators. These functions create a Row Context, allowing them to go through a specified table row by row, perform a calculation for each row, and then aggregate the results.

Here’s a classic example of a calculated column using Row Context. Imagine you have a 'Sales' table with [Quantity] and [UnitPrice] columns. You want to add a new column, LineTotal, to calculate the total for each sale. Your DAX would be:

LineTotal = Sales[Quantity] * Sales[UnitPrice]

Power BI evaluates this formula for every single row in the 'Sales' table. For the first row, it takes the quantity and unit price from that row and multiplies them. Then it moves to the second row and does the same, and so on, until the column is filled. The formula understands which values to use because it is operating within the Row Context.

The key takeaway is this: Filter Context filters your entire data model, while Row Context looks at one row at a time within a single table.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

So, What is Query Context?

Now that we have the building blocks, we can finally talk about Query Context.

Here’s the simple truth: Query Context is just another name for the initial Filter Context that is defined by the visuals on your report page, before any explicit DAX measure logic (like the CALCULATE function) is even considered.

It’s the invisible set of filters that Power BI's MQuery language creates. It's the sum total of all user selections on your report - the slicers they've picked, the bars on a chart they've clicked, and the filters in the filter pane they've applied.

When you place a measure like Total Sales = SUM(Sales[SalesAmount]) into a visual, it automatically honors the Query Context it is placed in. Again, using our sales dashboard example:

  1. You have a card showing Total Sales. It shows the grand total of all sales because there are no filters applied yet. The Query Context is empty.
  2. You have a slicer for ‘Year.’ You select 2023. A Query Context of [Year] = "2023" is created. The Total Sales card automatically updates to show only the sales from that year.
  3. You have a bar chart of Sales by Category. You click the "Electronics" bar. That action adds to the context. The Query Context is now [Year] = "2023" and [Category] = "Electronics". The Total Sales card updates again.

The term "Query Context" simply refers to this natural, user-driven filtering environment before special DAX functions start modifying it. For practical purposes, when you're starting, you can think of Query Context and Filter Context as the same thing.

Why Does This Stuff Even Matter?

Understanding context is not just academic, it's the most practical DAX skill you can have. Here’s why mastering it changes the game:

  • It's The Engine of Interactive Reports: The whole point of Power BI is to build dynamic, clickable reports that let users explore data. This interactivity is powered entirely by how visuals create and modify Filter/Query Context.
  • You Can't Write Correct Measures Without It: If you write a DAX measure and get an unexpected result (like the same grand total repeating for every row in a table), it is almost always a problem with context. You're likely confusing Row Context with Filter Context.
  • It's How You Control Calculations: The real power of DAX comes when you start manipulating context. Functions like CALCULATE are powerful because they allow you to add, modify, or even remove filters from the context before making a calculation. For instance, if you wanted a measure for "% of All Sales," you would need to calculate the sales for the current context and divide it by the sales of all categories. For that, you use DAX to remove the filter on category.

Common Sticking Points & Best Practices

As you get started, you will likely run into some common issues related to context. Here’s how to troubleshoot them.

Pitfall: Calculating a Sum in a Calculated Column

A very common beginner mistake is to try and write this formula as a new calculated column in the 'Sales' table:

// This does NOT work as you might expect in a Calculated Column
TotalSalesColumn = SUM(Sales[SalesAmount])

You would expect each row to show that specific row's sales, but instead, you will see the grand total of all sales repeated over and over down the entire column. Why? Because SUM operates over a Filter Context. A calculated column operates in a Row Context, which doesn’t have any inherent filters. So for every single row, SUM looks at the entire 'Sales' table and sums it all up.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Best Practice: Prioritize Measures Over Calculated Columns

For aggregations (like sums, averages, counts), always create a measure, not a calculated column. Measures are designed to live in visuals and respond to the Query Context. Calculated columns are static, calculated once during data refresh, and add to the size of your data model.

Rule of Thumb:

  • Use a calculated column when you need a value that is fixed based on other data in the same row (like Price * Quantity). You might want to use this new column as a filter or slicer later.
  • Use a measure for pretty much any aggregation you want to show in a visual (Total Sales, Average Order Value, Customer Count).

Best Practice: Start with a Table or Matrix

When you write a new measure, don’t immediately put it in a complex visual. Add it to a simple table or matrix first. This lets you clearly see how the measure’s value changes depending on the rows and columns (the Filter Context) in that matrix. Add a slicer and watch how the values react. This is the fastest way to sanity-check your DAX logic.

Final Thoughts

Learning the difference between evaluation contexts is like learning grammar for data analysis - it's the fundamental structure that every calculation is built on. Query Context is simply the starting place: the collection of filters that users naturally apply by clicking around your report. Understanding this lets you architect interactive experiences and write DAX measures that deliver accurate, dynamic insights.

Frankly, mastering concepts like Query Context and DAX syntax is exactly why many people find traditional BI tools so challenging. We designed Graphed to bypass that steep learning curve entirely. Instead of spending hours learning to manipulate context, you can just connect your marketing and sales platforms (like Google Analytics, Shopify, or Salesforce) and use plain English to ask what you need, like, "Show me a chart of total sales by country last month." We turn that request into a live, interactive dashboard instantly, so you can focus on insights instead of formulas.

Related Articles