Sub topic 1
Many-to-Many Relationships and Bridge Tables in Power BI
Prerequisites
Assume you can use Power BI Desktop's Model view and understand fact tables, dimension tables, relationships, one-to-many cardinality, SUM, and CALCULATE.
Starting point: facts and dimensions
A fact table stores events or measurements, such as orders, transactions, or hours. A dimension table stores descriptive fields used to group and filter those events, such as customers, products, or dates.
A star schema usually has one fact table in the center and several dimensions around it. Each dimension has one row per key. The fact table can contain many rows for each dimension key.
Cardinality and how filters travel
Cardinality describes how many matching rows exist between two related tables.
| Cardinality | Meaning | Common example |
|---|---|---|
| One-to-many | One key matches many rows | Products to Transactions |
| One-to-one | Each key matches one row | Employee to Employee Details |
| Many-to-many | Keys can repeat in both tables | Customers to Accounts |
In a typical one-to-many relationship, a filter travels from the one side to the many side. Selecting a product filters Transactions, so a measure such as total sales shows that product's value.
Cross-filter direction
Cross-filter direction controls which way filters move across a relationship.
- Single allows filtering from the dimension to the fact. This is the usual star-schema setting.
- Both allows filters to move in both directions.
Both-direction filtering can make a selection travel through multiple tables, but it can also create ambiguous paths, unexpected totals, and slower reports.
> callout note > Prefer single-direction relationships unless the model requires another path. If you use Both, test totals and filter behavior with realistic selections. > ```
Where many-to-many comes from
A true many-to-many relationship exists when a row on either side can relate to several rows on the other side. For example, one customer can use several accounts, and one account can be shared by several customers.
Many-to-many data often appears in enrollment, account ownership, project staffing, and tagging systems. Connecting these tables directly can make filter paths and totals difficult to interpret.
The native many-to-many relationship
Power BI supports a native many-to-many cardinality setting. You can connect two columns where values repeat on both sides and choose Many to many in the relationship dialog.
This is convenient for simple filtering, but it does not explain how a shared value should contribute to totals. If one account belongs to three customers, summing customer-level results can count that account's transactions three times. Use a bridge table when you need explicit keys, controlled filter flow, allocation rules, or easier validation.
Exercise
A customer can own several accounts, and an account can have several customers. What cardinality describes this relationship, and what risk should you test?
Show answer
It is many-to-many. Test for ambiguous filtering and double-counted totals when shared accounts appear under multiple customers.