Sub topic 1
What Filter Context Is
Every DAX measure returns a value for a specific set of rows in your model. Filter context is the name for that set of rows. This chapter explains what it is, where it comes from, and how to read it in a report. Later chapters build on it to show how CALCULATE changes it.
Prerequisites
This chapter assumes you already know the following:
- How to write a basic DAX measure and how it differs from a calculated column.
- What a star schema is: fact tables such as
Saleson the many side, and dimension tables such asProduct,CustomerandDateon the one side of one-to-many relationships. - How a report works. Slicers, rows, columns and filters on a visual all change what a measure shows.
The examples use a small model with a Sales fact table and a Product dimension. A measure is defined like this:
Total Sales = SUM ( Sales[Amount] )The definition
Filter context is the set of filters that is active when DAX evaluates an expression. Each filter limits the rows that are visible in one or more columns. An aggregation such as SUM only sees the rows that survive all of these filters.
The formula SUM ( Sales[Amount] ) never changes. Its result changes because the filter context changes. This is the single most important idea in DAX: a measure has no fixed value. It has a value for a given filter context.
Filter context is made of column filters. A filter says, for example, "'Product'[Color] is one of Red or Blue". It does not select individual rows by position. It restricts the allowed values in a column. A table's visible rows are the rows whose values satisfy every column filter on that table.
Where filter context comes from
In a report, filter context is built from several sources. They all combine with AND logic across different columns.
| Source | Example | Filter produced |
|---|---|---|
| Row or column header of a table or matrix | Product category `Bikes` on a row | `'Product'[Category] = "Bikes"` |
| Slicer | Year slicer set to 2025 | `'Date'[Year] = 2025` |
| Visual-level, page-level or report-level filter | Color is not Black | `'Product'[Color] <> "Black"` |
| Cross-filtering from another visual | A bar selected in a chart | A filter on the bar's column value |
| Filter arguments in CALCULATE | `'Product'[Color] = "Red"` | Covered in later chapters |
Think of the last row as the one you control in code. The other rows are set by whoever uses the report.
A worked example
Suppose the Sales table holds these rows.
| Product Color | Product Category | Amount |
|---|---|---|
| Red | Bikes | 100 |
| Red | Helmets | 40 |
| Blue | Bikes | 80 |
| Blue | Helmets | 30 |
Consider a matrix with Category on the rows and no other filters. The measure [Total Sales] is evaluated once per row of the matrix, and once for the grand total.
| Matrix cell | Filter context | Result |
|---|---|---|
| Bikes row | `Category = "Bikes"` | 180 |
| Helmets row | `Category = "Helmets"` | 70 |
| Grand total | No filters | 250 |
Now add a slicer that selects the color Red. Every cell gets one more filter.
| Matrix cell | Filter context | Result |
|---|---|---|
| Bikes row | `Category = "Bikes"` and `Color = "Red"` | 100 |
| Helmets row | `Category = "Helmets"` and `Color = "Red"` | 40 |
| Grand total | `Color = "Red"` | 140 |
The formula is identical in all six cells. Only the filter context differs.
Filter context applies to every column
A filter on one column also affects other columns of the same table. After the filter Color = "Red", the Product table shows only red products. Any column in that table now has only the values that appear on red products. A category that has no red product disappears from the visible rows.
This is why filters are best described as sets of allowed values for a column. Several filters on different columns intersect. Several values within one column's filter act as OR.
| Selection | Meaning |
|---|---|
| `Color` in {Red, Blue} | Color is Red OR Blue |
| `Color` in {Red, Blue} and `Category` in {Bikes} | (Red OR Blue) AND Bikes |
Filters travel across relationships
Filter context is not limited to the table whose column is filtered. Along a one-to-many relationship, a filter on the one side (Product) passes to the many side (Sales). That is how a filter on 'Product'[Color] reduces the rows of Sales that SUM ( Sales[Amount] ) aggregates.
By default the filter does not travel the other way. A filter on Sales does not restrict Product, unless the relationship has a bidirectional cross-filter direction. The next chapter covers propagation in detail. For now, remember that "visible rows" applies to the whole connected model, not to a single table.
Seeing filter context in a measure
A few functions let a measure inspect the filter context, so you can check what you think is active.
Selected Colors =
CONCATENATEX (
VALUES ( 'Product'[Color] ),
'Product'[Color],
", ",
'Product'[Color], ASC
)VALUES ( 'Product'[Color] ) returns the colors that remain visible under the current filter context. Put this measure in a matrix next to [Total Sales] and the connection becomes visible. With a Red slicer it returns Red. With no filter it returns Blue, Red.
Two related checks are common:
Is Color Filtered =
ISFILTERED ( 'Product'[Color] )
Colors Visible =
COUNTROWS ( VALUES ( 'Product'[Color] ) )ISFILTERED returns TRUE when a filter applies directly to that column. It returns FALSE when the column is restricted only indirectly, for example by a filter on another column in the same table. Use ISCROSSFILTERED when you want to include indirect filtering.
Filter context in the evaluation of a measure
DAX evaluates a measure cell by cell. For each cell of a visual, the engine:
- Builds the filter context from the headers, slicers and filters that apply to that cell.
- Evaluates the measure expression against the rows that remain visible.
- Returns the result to that cell.
Because of step 1, a measure does not need to know which visual displays it. The same [Total Sales] works in a card, a chart, a matrix and a tooltip.
Common beginner errors
Several mistakes come from forgetting that filter context is invisible in the formula text.
- Reading a measure as a fixed number.
[Total Sales]is not "all sales". It is the sales visible in the current context. Test it in an empty card, then in a filtered matrix. - Expecting a calculated column to react to slicers. A calculated column is computed when the model is refreshed. It has no report filter context at that time, so it never changes when a user clicks a slicer. A measure is evaluated at query time and does respond.
- Assuming a filter on the many side filters the one side. With default one-directional relationships, selecting rows in
Salesdoes not hide products inProduct. - Confusing a hidden filter with no filter. A page-level or report-level filter is part of the filter context even when it is not visible on the canvas. If a number looks too small, list the filters on every level.
What comes next
Filter context decides which rows a measure sees. It is only half of the picture. DAX also has row context, which iterates over rows but does not filter anything. CALCULATE is the function that lets you edit filter context from inside a formula. The following chapters cover filter propagation, row context, and then CALCULATE itself.
Exercise
A matrix shows Category on the rows. A slicer selects Color = "Blue". Using the Sales table in this chapter (Red Bikes 100, Red Helmets 40, Blue Bikes 80, Blue Helmets 30), what does [Total Sales] return in the Bikes row, the Helmets row and the grand total? State the filter context for each.
Show answer
Bikes row: filter context is Category = "Bikes" and Color = "Blue", so the result is 80. Helmets row: Category = "Helmets" and Color = "Blue", so the result is 30. Grand total: only Color = "Blue", so the result is 110, which equals 80 + 30. The formula is the same in every cell. Only the filter context changes.
Exercise
You add a calculated column Sales[Is Red Total] = SUM ( Sales[Amount] ) and place it in a table visual with a slicer on color. Why does it show the same number on every row, regardless of the slicer?
Show answer
A calculated column is computed at refresh time over the whole table, with no report filter context. There is no slicer selection at that moment, so SUM aggregates all rows. Slicer clicks happen later and cannot change a stored column value. A measure is the right tool when the result must respond to the report's filters.