Sub topic 1
What filter context is
Prerequisites
Assume you know basic DAX measures and calculated columns. You should also understand star-schema models, one-to-many relationships, and how slicers and visual rows filter a measure.
Filter context
Filter context is the set of filters active when DAX evaluates an expression. A slicer, a visual row, a page filter, or a filter written in DAX can add to this set.
A measure reads the current filter context. The same measure can therefore return different results in different parts of a report.
Total Sales = SUM ( Sales[Amount] )For example, a card with no product filter may show all sales. A visual row for Product[Category] = "Bikes" evaluates the same measure with only Bikes-related sales available.
How filters flow through relationships
In a star schema, dimension tables usually filter fact tables through relationships. A filter on Product[Color] travels across the relationship to the related rows in Sales.
This propagation depends on the relationship's direction, cardinality, and active status. If the relationship is missing or inactive, the filter may not affect the fact table as expected.
Row context and why it does not filter
Row context means that DAX is evaluating one row at a time. Calculated columns have row context automatically. Iterators such as AVERAGEX also create row context.
Row context lets you read the current row, but it does not automatically filter related tables or change a measure's result. A filter context and a row context are different concepts.
CALCULATE modifies the context
CALCULATE evaluates an expression after changing its filter context. Its arguments can add, replace, remove, or preserve filters.
Red Sales =
CALCULATE (
[Total Sales],
'Product'[Color] = "Red"
)This measure evaluates [Total Sales] with a Red filter. By default, a Boolean filter on the same column replaces that column's existing filter. Later chapters examine this behavior and context transition, where CALCULATE converts row context into filter context.
Exercise
A report row filters Product[Color] to Blue. What color does Red Sales calculate?
Show answer
Red. The Boolean filter in CALCULATE replaces the existing filter on Product[Color].