Sub topic 3
Cross-filter direction
This chapter assumes you can work in Power BI Desktop model view, know the difference between fact and dimension tables, understand one-to-many relationships, and can write basic DAX with SUM and CALCULATE. It covers the setting that decides which way a filter travels across a relationship, and the problems that follow when you change it.
What cross-filter direction controls
Every relationship in a Power BI model has a cross-filter direction. It decides which table's filters can reach the other table.
- Single: filters flow from the "one" side to the "many" side only. This is the default for one-to-many relationships.
- Both: filters flow in either direction. Power BI also calls this bidirectional filtering.
Take a small model. Customers is a dimension and Sales is a fact table. Each customer has many sales rows. The relationship is Customers[CustomerID] (one) to Sales[CustomerID] (many).
With a single direction, a slicer on Customers[Region] filters Sales. A slicer on Sales[Channel] does not filter Customers. A visual that lists customers beside a Channel slicer would still show every customer.
Why the default is single
The single direction is the default for three reasons.
- It matches how star schemas are read. Dimensions hold the descriptive attributes people slice by. Facts hold the numbers. Filtering from dimension to fact is almost always what you want.
- It is predictable. Each filter has one route to any table, so you can trace a result by hand.
- It is cheap. The engine does not have to propagate filters back up the model.
Bidirectional filtering gives up all three in exchange for reach. Use it when a specific question needs it, not as a general fix for a visual that shows unexpected rows.
What "both" does in practice
Suppose you want a slicer that lists only the customers who bought a given product. The model has Products and Customers, both one-to-many into Sales.
With single filters, selecting a product filters Sales. The filter stops there. Customers is unaffected, so the slicer lists everyone.
If you set the Customers to Sales relationship to Both, the filter on Sales continues up to Customers. The customer slicer now shows only customers with at least one matching sale.
You change the setting in the relationship's properties dialog. Open it by double-clicking the relationship line in model view, then choose Both in the Cross-filter direction dropdown.
A cheaper alternative for this particular case is to leave the relationship alone and show only matching items with a visual-level filter, such as a measure that returns a value only where sales exist. The bidirectional setting is a model-wide change, so reach for lighter options first.
Direction and cardinality
The choices available to you depend on the relationship's cardinality.
| Cardinality | Single direction | Both directions |
|---|---|---|
| One-to-many | One side filters many side (default) | Allowed |
| One-to-one | Not applicable. Both tables filter each other | Always both |
| Many-to-many | One table filters the other, you pick which | Allowed |
A one-to-one relationship always filters both ways, because neither table is a "one" side that could be favored. A native many-to-many relationship lets you pick the direction, and its default is single. The next chapters return to this.
Gotchas with bidirectional filtering
Bidirectional filtering is a legitimate tool, but it has costs that show up only as a model grows.
Ambiguous filter paths
If two routes connect the same pair of tables, the engine cannot choose between them. Power BI warns you when you create such a relationship and marks one of the relationships inactive.
Consider Customers, Sales, and Stores. If Stores relates to Customers and to Sales, and Customers also relates to Sales bidirectionally, a filter on Stores can reach Sales along two paths. The result depends on which path is used, and Power BI will not accept the ambiguity.
Unexpected results
A bidirectional filter can change numbers on visuals you did not touch. A filter you meant to apply to one table now spreads further, and a measure that was correct yesterday returns a different value today. The effect is hard to find because nothing in the measure changed.
Performance
Every bidirectional relationship gives the engine more filter propagation to compute. On small models you will not notice. On large fact tables the cost can be real, especially when several bidirectional relationships chain together.
Row-level security
Security filters normally flow in the single direction, like other filters. Power BI Desktop lets you choose to apply security filters in both directions on a bidirectional relationship, which can expose or hide rows in ways that are easy to get wrong. Test any role that touches a bidirectional relationship.
Controlling direction in a measure
You do not always have to change the relationship. DAX lets you change direction for a single calculation with the CROSSFILTER function. The model keeps its single-direction setting, and only the measure that asks for bidirectional filtering gets it.
Customers With Sales =
CALCULATE (
DISTINCTCOUNT ( Customers[CustomerID] ),
CROSSFILTER ( Sales[CustomerID], Customers[CustomerID], BOTH )
)When a product is selected, this measure counts only customers that have sales for that product, even though the relationship is single direction. The BOTH argument applies only inside this CALCULATE.
CROSSFILTER accepts three direction values:
| Value | Effect inside the calculation |
|---|---|
| `ONEWAY` | Filters flow from the one side to the many side |
| `BOTH` | Filters flow both ways |
| `NONE` | The relationship is ignored |
CROSSFILTER can only change the behavior of an existing relationship. It cannot create one. A later chapter covers CROSSFILTER in more detail, and shows TREATAS as the tool for cases without a relationship.
Why this matters for many-to-many
Many-to-many models put pressure on direction more than any other design. In a bridge pattern, the bridge sits between two dimensions, and a filter must travel from one dimension, through the bridge, and then onward to a fact table. A single-direction relationship from the bridge to a dimension blocks that trip.
That is why bridge setups often need bidirectional filtering on one relationship, or a measure that applies CROSSFILTER or TREATAS. The next chapters build the model and show where the direction must go. For now, remember the central question: for each relationship, which table needs to filter which, and does that need justify the cost?
A checklist for choosing a direction
Ask these questions in order for each relationship:
- Does the visual need a filter to travel from the many side back to the one side?
- Can a measure with
CROSSFILTERor a visual-level filter solve it without changing the model? - Will the change create a second path between any two tables?
- Do totals for unrelated visuals stay the same after the change?
- Does the relationship appear in a security role?
If you answer yes to the first question and no to the next three, a bidirectional setting is reasonable. Otherwise, keep it single.
Exercise
A model has Products and Customers, each in a one-to-many relationship with Sales. A report page has a Product slicer and a Customer slicer. Users complain that the Customer slicer lists customers who never bought the selected product. Name two ways to fix this and one risk of the first.
Show answer
Option 1: set the Customers to Sales relationship to Both, so the filter on Sales reaches Customers. Option 2: leave the model alone and use a measure with CROSSFILTER ( Sales[CustomerID], Customers[CustomerID], BOTH ), or a visual-level filter on a measure that is nonblank only where sales exist. A risk of option 1 is that the change applies to every visual and measure using those tables. It can alter other numbers, create ambiguous paths, and slow queries on large models.
Exercise
What is the default cross-filter direction for a one-to-many relationship, and which table filters which?
Show answer
The default is Single. The table on the one side (the dimension) filters the table on the many side (the fact table). A filter on the many side does not reach the one side.