Sub topic 9
When to use both-direction filtering, and its risks
This chapter assumes you can create a one-to-many relationship in the Model view. It also assumes you know that a filter normally travels from the "one" side to the "many" side. Both-direction filtering changes that rule. Use it deliberately, because it can slow reports and change totals.
What both-direction filtering does
By default, a relationship from Customer (one) to Sales (many) filters in a single direction. A slicer on Customer narrows Sales. A slicer on Sales does not narrow Customer.
When you set the cross-filter direction to Both, filters also travel from the "many" side back to the "one" side. A selection on Sales then narrows the Customer table.
placeholderA situation that needs it
Suppose you want a slicer that lists only customers who bought the product you selected in a Product slicer. The path is Product → Sales → Customer. The second step runs from Sales to Customer, which is against the default direction. Without both-direction filtering, the Customer slicer shows every customer.
Prefer a measure-level setting
You can avoid changing the model by turning on both-direction filtering inside one measure with CROSSFILTER. The relationship stays single-direction everywhere else.
Customers Who Bought =
CALCULATE (
DISTINCTCOUNT ( Customer[CustomerKey] ),
CROSSFILTER ( Sales[CustomerKey], Customer[CustomerKey], Both )
)This limits the effect to a single calculation. Other visuals keep the faster, more predictable behavior.
Risks
- Ambiguous paths. If two routes connect the same pair of tables, a both-direction relationship can create competing paths. Power BI may refuse to activate the relationship, or it may pick a route you did not intend.
- Unexpected totals. Filters spread to tables you did not mean to filter. A slicer on one dimension can now narrow another dimension, and results change in ways that are hard to trace.
- Slower performance. Each both-direction relationship adds work for the engine, and the cost grows on large tables.
- Hidden side effects. A later change elsewhere in the model can alter results of existing measures.
Safer practices
- Keep single direction as the default on all dimension-to-fact relationships.
- Use
CROSSFILTERin a measure when only one calculation needs the reverse flow. - If you do set Both in the model, apply it to one relationship at a time and recheck your totals.
- Avoid combining Both with several dimension tables joined to the same fact table that also link to one another.
Exercise
A Product slicer should limit a Customer slicer to customers who bought that product. The Customer-to-Sales relationship is single direction. Name two ways to get this result, and say which has less risk to the rest of the model.
Show answer
Either set the Customer-to-Sales relationship to Both, or use CROSSFILTER with Both inside a measure. The measure approach carries less risk, because the model's relationship stays single direction and other visuals are unaffected.