Sub topic 8
How filters flow from dimensions to facts
This chapter explains how a filter selected on a dimension table reaches the fact table, and what controls that path. It assumes you can open Model view in Power BI Desktop, you know what primary and foreign keys are, and you can read a simple DAX measure. It builds on the one-to-many relationships from the previous chapter.
The core idea: filters follow the "one" to the "many"
A one-to-many relationship has a direction built into it. The "one" side is the dimension, where the key is unique. The "many" side is the fact table, where the key repeats. By default, a filter travels from the one side to the many side.
When a user clicks "Bikes" in a slicer on DimProduct[Category], the engine does three things:
- It keeps only the rows in
DimProductwhere Category is "Bikes". - It follows the relationship on
ProductKeyto the fact table. - It keeps only the
FactSalesrows whoseProductKeymatches one of the remaining products.
A measure such as SUM ( Sales[SalesAmount] ) then adds up only those surviving fact rows. The measure contains no filter logic. The filter comes from the model.
Filter context
Every cell in a visual is calculated in a filter context. This is the set of filters active for that calculation. Filters come from several places:
- Slicers and page, report, or visual-level filters.
- The row and column fields of the visual. A row labeled "2024" adds a filter on Year.
- Filters written inside the measure, for example with
CALCULATE.
The engine combines all of these, pushes them through the relationships, and then evaluates the measure against what is left in the fact table. This is why one measure can show a different number in every cell of a matrix.
Seeing it work
Take two small tables. This is the product dimension:
| ProductKey | ProductName | Category |
|---|---|---|
| 1 | Road Bike | Bikes |
| 2 | Helmet | Accessories |
| 3 | Mountain Bike | Bikes |
This is the fact table:
| OrderNumber | OrderLineNumber | ProductKey | SalesAmount |
|---|---|---|---|
| SO1 | 1 | 1 | 1200.00 |
| SO1 | 2 | 2 | 45.00 |
| SO2 | 1 | 3 | 900.00 |
| SO3 | 1 | 1 | 1100.00 |
With the filter Category = Bikes, products 1 and 3 remain. The fact rows for SO1 line 1, SO2 line 1, and SO3 line 1 survive. The measure returns 3200.00. The Helmet row is excluded because its key was removed from the dimension.
The reverse does not happen by default. Selecting a single row in the fact table does not filter the dimension.
Measures that rely on the flow
The measures from the spine are written against fact columns only:
Total Sales = SUM ( Sales[SalesAmount] )
Total Quantity = SUM ( Sales[Quantity] )Place Product[Category] on the rows of a table visual with [Total Sales] as the value. Each row adds a Category filter, the relationship carries it to Sales, and the sum is computed per category. Place 'Date'[Year] on columns and each cell gets both a Category and a Year filter. Both filters reach the same fact table, and the engine intersects them.
Fields used in a visual should come from the dimension, not from the fact table. If you put Sales[ProductKey] on the rows, you get one row per key with no descriptive context, and you bypass the filter path that the model was designed for.
Filtering from several dimensions at once
A star schema has several dimensions around one fact table. Each dimension filters the fact table independently. When a user selects a Category, a Year, and a Region, the fact table receives three filters, and a fact row must satisfy all three.
Dimensions do not filter each other directly. A Region filter does not remove products from the Product slicer, because the filter reaches Sales and stops there. The fact table does not pass it on to DimProduct. If you want a product slicer to show only products that were sold in the selected region, you need a different technique, such as a measure used as a visual filter, or a deliberate change to the filter direction.
Cross-filter direction
Each relationship has a cross-filter direction setting:
| Setting | Behavior |
|---|---|
| Single | Filters flow only from the one side to the many side. This is the default and the right choice for a star. |
| Both | Filters flow in both directions. The fact table can also filter the dimension. |
It is tempting to switch to Both to make slicers "cascade". Be careful with it. Bidirectional filters cause three kinds of problems:
- Ambiguity. If two filter paths can connect the same pair of tables, the engine cannot choose between them. Power BI will disable or reject one of the relationships.
- Unexpected results. Filters spread to tables you did not intend to filter, so totals change depending on which slicers are on the page.
- Slower queries. The engine has to do extra work to propagate filters in both directions.
Use single direction as the default. Reach for Both only when you have a specific need, such as a many-to-many scenario, which a later chapter covers.
Active and inactive relationships
Between any two tables, only one relationship can be active at a time. The active relationship is the one used by default. An inactive relationship appears as a dashed line in Model view. It exists in the model but does nothing until a measure asks for it.
This is how one date dimension can serve both order date and ship date. Sales[OrderDateKey] holds the active relationship to 'Date'[DateKey]. Sales[ShipDateKey] holds an inactive one. A measure then switches the path for its own calculation:
Sales by Ship Date =
CALCULATE (
[Total Sales],
USERELATIONSHIP ( Sales[ShipDateKey], 'Date'[DateKey] )
)The filter still flows from the dimension to the fact table. Only the key column used to match rows changes. A visual with 'Date'[Year] on the rows now shows sales grouped by the year the order shipped. A later chapter covers role-playing dimensions in more detail.
Common problems and how to check them
When a number looks wrong, check the filter path before changing the measure.
- A slicer has no effect. The dimension is probably not related to the fact table. Open Model view and look for a line between them. Also check that the relationship is not inactive.
- A matrix shows the same total on every row. The row field comes from a table with no relationship to the measure's table. The filter has nowhere to go, so each row sees all fact rows.
- A blank row appears in a visual. The fact table has key values that do not exist in the dimension. Power BI adds a blank member to the dimension to hold these orphan rows. Fix the data or the dimension load, not the visual.
- The relationship is many-to-many. The key column in the dimension contains duplicates. Filtering is then less predictable. Make the dimension key unique, usually by removing duplicates in Power Query.
- A filter works in one direction only. That is expected with single direction. Decide whether you actually need the reverse.
Summary of the rules
- Filters move from the one side to the many side by default.
- Slicers, visual fields, and filters inside measures all combine into the filter context.
- Several dimensions filter one fact table independently, and the fact rows must satisfy all of them.
- Dimensions do not filter one another through the fact table in a single-direction model.
- Only one relationship between two tables is active.
USERELATIONSHIPactivates an inactive one inside a measure.
Exercise
A report has a Category slicer on the Product dimension and a Region slicer on the Geography dimension, both related to Sales with single-direction, one-to-many relationships. A user selects Region = "West". Why does the Category slicer still list categories that have no sales in the West, and what is one way to change that?
Show answer
With single-direction relationships, the Region filter travels from Geography to Sales and stops there. It does not continue from Sales to Product, so the Category slicer is not affected. To make the slicer respond, you can set the Product-to-Sales relationship to filter in both directions, but this adds the ambiguity and performance risks described above. A safer option is to add a visual-level filter to the Category slicer using a measure such as Total Sales, set to show items where the value is not blank.
Exercise
A matrix has Product[Category] on the rows and [Total Sales] as the value. Every row shows the same grand total. Name two things you would check in Model view.
Show answer
First, check whether a relationship exists between Product and Sales, and whether it is active, since without one the Category filter never reaches the fact table. Second, check that the Category column comes from the dimension related to Sales and not from a separate, unrelated table with the same field name.