Sub topic 4
How role filters travel through relationships
This chapter assumes you can build a star schema in Power BI Desktop, write simple DAX comparisons, and have already created a basic role with a table filter expression. Here you will see how a filter on one table reaches the others, and where that stops working.
A role filters one table, and relationships do the rest
A role holds a DAX table filter expression on a table, such as [Region] = "West" on a Region dimension. The role does not touch the Sales fact table directly. Power BI applies the filter to Region, and the relationship between Region and Sales carries it down to the matching fact rows.
The filter follows the same direction as a normal slicer. It moves from the "one" side of a one-to-many relationship to the "many" side. So filtering a dimension restricts the fact table, but filtering a fact table does not restrict the dimension.
An example
Suppose the model has these tables:
| Table | Type | Key column |
|---|---|---|
| Region | Dimension | RegionID |
| Product | Dimension | ProductID |
| Sales | Fact | RegionID, ProductID |
Both dimensions have a one-to-many relationship to Sales. You create a role named WestOnly with this filter on Region:
[Region] = "West"A member of WestOnly sees only West rows in Region. Because Region filters Sales, a total of sales in a card visual includes only West transactions. The Product table is not filtered by this role. A member still sees every product name in a slicer, even products with no West sales. The values in a visual remain correct, but the list of members is not hidden.
Common ways propagation fails
Most "the role did nothing" problems come from the relationship, not the DAX.
- Wrong filter direction. If you put the filter on a fact table and expect a dimension to shrink, nothing happens. Place the filter on the dimension, or on the table that sits on the "one" side.
- Inactive relationship. Role filters do not travel through inactive relationships. If the link between
RegionandSalesis inactive, the role filtersRegionand leavesSalesunrestricted. This exposes data. - Missing relationship. If two tables are not related, a filter on one never reaches the other.
- Single direction between a security table and a dimension. A mapping table must filter the dimension, which is covered in the later chapter on security tables.
Check what the role sees
Test propagation by choosing View as in Desktop, selecting the role, and looking at a table visual from the fact table. Add a measure that counts fact rows, for example:
Sales Rows = COUNTROWS ( Sales )Compare the count with and without the role. If the number does not drop, the filter is not reaching Sales. Open Model view and check that the relationship is active and points from the dimension to the fact table.
Exercise
A role filters the Product table with [Category] = "Bikes". The relationship from Product to Sales is inactive. What does a member of this role see in Sales, and why?
Show answer
The member sees all Sales rows. The role filters Product, but role filters do not travel through inactive relationships, so the filter never reaches Sales. The fix is to make the relationship active.
Exercise
You apply the filter [Amount] > 1000 on the Sales fact table. Does the Region dimension shrink to only the regions with large sales?
Show answer
No. Filters flow from the one side to the many side, so a filter on Sales does not reduce Region unless you enable the security filter in both directions on that relationship.