Sub topic 2
The Bridge Table Pattern
This chapter assumes you know Power BI model view, fact and dimension tables, one-to-many relationships, and basic DAX measures.
The bridge table pattern
A bridge table resolves a true many-to-many relationship by storing each valid pair of keys once. Suppose one account can belong to several customers, and one customer can use several accounts. A direct relationship between Customers and Accounts can create unclear filter paths.
Instead, place the pairs in an AccountBridge table:
Customers[CustomerID]has one row per customer.Accounts[AccountID]has one row per account.AccountBridgehas one row per customer-account pair.Transactionsstores amounts and relates toAccounts.
The bridge changes one many-to-many relationship into two one-to-many relationships.
Building the bridge table
The bridge must contain unique pairs. Duplicate pairs can multiply rows and produce incorrect totals. In Power BI, create it as a calculated table:
AccountBridge =
DISTINCT (
SELECTCOLUMNS (
AccountCustomer,
"AccountID", AccountCustomer[AccountID],
"CustomerID", AccountCustomer[CustomerID]
)
)SELECTCOLUMNS keeps only the keys needed for filtering. DISTINCT removes repeated pairs. Check that every AccountID and CustomerID exists in its matching dimension. Missing keys create unmatched rows that cannot filter the model as expected.
Wiring the bridge: relationships and filter direction
Create these relationships:
| From | To | Cardinality | Default direction |
|---|---|---|---|
| Customers[CustomerID] | AccountBridge[CustomerID] | One to many | Single |
| Accounts[AccountID] | AccountBridge[AccountID] | One to many | Single |
The default setup lets a customer filter the bridge, but the filter stops there. To let that selection reach Accounts and then Transactions, set the relationship between AccountBridge and Accounts to Both. This allows filters to travel from the bridge back to the account dimension.
Bidirectional filtering is convenient, but it can create ambiguous paths and slower queries when other relationships already connect these tables. Use it only where the model needs it. Keep other relationships single-direction unless there is a clear reason to change them.
Exercise
Why must the bridge contain unique CustomerID and AccountID pairs?
Show answer
Duplicate pairs can repeat filter paths and cause incorrect counts or totals.