Sub topic 8
Wiring the bridge: relationships and filter direction
This chapter assumes you can use Power BI Desktop model view, know the terms fact table and dimension table, understand one-to-many relationships, and can write basic DAX with SUM and CALCULATE. The bridge table already exists. Now you connect it so filters reach the fact table.
The model to wire
The example has four tables:
- Customers: one row per customer, with a unique
CustomerID. - Accounts: one row per account, with a unique
AccountID. - AccountBridge: unique pairs of
AccountIDandCustomerID. - Transactions: the fact table, with an
AccountIDand anAmount.
An account can belong to several customers, and a customer can hold several accounts. The bridge stores each pairing once.
Create the two relationships
Both relationships run from a dimension to the bridge, so the dimension is on the one side and the bridge is on the many side.
| From (one side) | To (many side) | Cardinality | Cross-filter direction |
|---|---|---|---|
| Customers[CustomerID] | AccountBridge[CustomerID] | One-to-many | Single |
| Accounts[AccountID] | AccountBridge[AccountID] | One-to-many | Single (default) |
| Accounts[AccountID] | Transactions[AccountID] | One-to-many | Single |
With single direction, a filter travels from the one side to the many side. A Customer selection filters the bridge, but it stops there. The bridge does not filter Accounts, so Transactions never sees the selection.
The second hop goes against the one-to-many direction, from the many side back to the one side. That hop is the one you must enable.
Three ways to open the second hop
- Set the relationship to Both. Edit the Accounts to AccountBridge relationship and set cross-filter direction to Both. Every visual in the report now uses this path.
- Use CROSSFILTER in a measure. The model stays single direction, and one measure turns on Both for its own calculation.
- Use TREATAS. No filter propagation is needed, because the measure copies the visible keys onto the fact table.
Setting Both is the quickest option. It also has costs. It can create ambiguous filter paths when other relationships join the same tables. Power BI then makes one of them inactive or refuses to create it. It can also slow queries, because filters flow in more directions. Lastly, it changes the result of every measure that touches these tables, including measures you did not intend to change.
The measure-level option
Keep the relationship on Single and switch direction only where you need it.
Total Amount = SUM ( Transactions[Amount] )Amount via Bridge =
CALCULATE (
SUM ( Transactions[Amount] ),
CROSSFILTER ( AccountBridge[AccountID], Accounts[AccountID], BOTH )
)Place Customers[CustomerName] in a table visual next to both measures. Total Amount repeats the same grand total on every row, because the customer filter never reaches Transactions. Amount via Bridge shows each customer's own accounts.
Common errors
- Every row shows the same number. The bridge-to-Accounts hop is still single direction. Check the relationship line for a single arrow.
- Relationship cannot be created or is inactive. Another path already connects the same tables. Remove it or keep it inactive.
- The one side is not unique. If
Customers[CustomerID]orAccounts[AccountID]has duplicates, Power BI cannot make a one-to-many relationship. Fix the dimension. - Unexpected totals. A shared account counts once per customer in a visual. The next chapter covers this.
Exercise
A report has Customers → AccountBridge and Accounts → AccountBridge, both one-to-many with single direction, and Accounts → Transactions single. Selecting a customer does not change Total Amount. Which relationship needs to change, to what, and what is the alternative that leaves the model unchanged?
Show answer
The Accounts → AccountBridge relationship needs cross-filter direction Both, so the filter can go from the bridge up to Accounts and then down to Transactions. The alternative is a measure that wraps SUM in CALCULATE with CROSSFILTER ( AccountBridge[AccountID], Accounts[AccountID], BOTH ), which applies Both for that measure only.