Filter context
Start with the visible set of sales lines
Filter context determines which data a calculation can see. A measure is not a fixed spreadsheet cell: the same definition can answer several questions as report selections change. In this lesson we use the existing five-line retail Import model, labs/fixtures/dimensional-v1/fact-sales.csv, labs/fixtures/products.csv and dim-region.csv in the dimensional-v1 folder. Name the tables FactSales, DimProduct and DimRegion. Use text keys, whole-number USD fields and active one-to-many relationships from each dimension to FactSales, with single-direction filtering. You may reuse the full clean V007 model if its other dimensions remain unfiltered. No RLS, custom totals or visual calculations are enabled. Native execution has not been run.
Example 1 — one measure, different cells
Create this new measure in FactSales (not a calculated column):
Context Revenue = SUM(FactSales[RevenueUSD])A matrix with DimRegion[Region] on rows, DimProduct[Product] on columns and Context Revenue in Values supplies a different selection to each cell. The dimensions restrict fact rows through the active paths. With no other filters, the expected matrix is:
| Region | Notebook | Desk Lamp | Backpack | Total USD |
|---|---|---|---|---|
| North | 24 | 30 | 50 | 104 |
| South | 36 | 60 | BLANK | 96 |
| Total | 60 | 90 | 50 | 200 |
The South/Backpack intersection matches no rows, not a recorded zero sale. A visual may show an empty cell or omit an empty grouping; these are predicted model results, not a screenshot. Each subtotal keeps its own group restrictions. The grand total sees all five rows in this unfiltered report.
Example 2 — trace a filter intersection
Select North in a DimRegion slicer and Notebook in a DimProduct slicer, both interacting with the card. The first restricts the fact to L01, L02, L04. The second allows L01, L03. Their intersection is L01, so the card shows 24 USD. Changing the product to Desk Lamp gives L02 and 30 USD; clearing the product selection while keeping North gives 104 USD. Clearing both gives 200 USD. Slicers on independent columns typically intersect; selecting two values within one slicer permits either selected value. For North or South together and Notebook only, the card is 60 USD. A query's grouping and report selections provide context for each cell; query context is a useful description of that process, not a third independent row cursor. A separate DAX Query View query does not automatically inherit a report page's slicers.
Debug the context before editing a formula
If the region card repeats 200 for every region, inspect the active relationship, key matching, field origin and visual interactions before changing the measure. In a single-direction star, filtering a fact column does not automatically filter its lookup dimension backwards. Filtering does not delete rows from the imported source. Do not assume every report filter reaches every visual: edit interactions, filters scoped to individual visuals, inactive relationships and disconnected tables may change what reaches the measure. Formulas can also alter their own filter context; Chapter 21 explains CALCULATE. The current examples intentionally do not alter it.
Practice — predict the selected lines
With the same clean model, predict South + Desk Lamp, North + Notebook or Desk Lamp, and South + Backpack. List line IDs, revenue, and whether the result is blank or numeric. Explain what happens when only the region slicer is cleared. Verify on paper before using the optional local lab.