Sub topic 2
Cardinality and how filters travel
This chapter assumes you can open Model view in Power BI Desktop, know the difference between a fact table and a dimension table, and can write basic DAX measures with SUM and CALCULATE. It covers how a relationship's cardinality decides which rows a filter reaches.
What cardinality describes
Cardinality is the count relationship between the rows of two tables, matched on a pair of columns. Power BI offers these types:
| Cardinality | Meaning | Typical use |
|---|---|---|
| One-to-many (1:*) | The "one" side has unique key values. The "many" side repeats them. | Dimension to fact table |
| One-to-one (1:1) | Both sides have unique key values. | Splitting one table in two |
| Many-to-many (*:*) | Neither side is required to be unique. | Covered in later chapters |
In a star schema, most relationships are one-to-many. The dimension table sits on the "one" side, and the fact table sits on the "many" side. A Customers table with one row per customer, joined to a Sales table with many rows per customer, is the standard example.
How a filter travels
A filter is a restriction on the rows of a table, such as Customers[Country] = "Spain". A relationship carries that restriction to the related table. With the default single cross-filter direction, the filter moves from the "one" side to the "many" side only.
Suppose a slicer selects Spain. The steps are:
- The slicer filters
Customersto the Spanish rows. - The relationship passes the remaining
CustomerIDvalues toSales. Saleskeeps only rows whoseCustomerIDmatches.- A measure such as
SUM ( Sales[Amount] )adds up only those rows.
Total Amount = SUM ( Sales[Amount] )Placed in a visual next to Customers[Country], this measure returns one value per country. Each value is correct because every Sales row belongs to exactly one customer.
Why the direction matters
The reverse does not hold. Selecting a single Sales row does not narrow the Customers table, because single direction blocks the "many" to "one" path. A visual that shows Customers[Name] next to a measure over Sales still works, because the filter travels from the visual's Customers column to Sales. A slicer built on a Sales column will not filter the customer list.
A filter reaches only the tables it can follow a relationship path to. If no path exists, the filter has no effect, and the measure ignores it.
What changes with many-to-many
In a one-to-many relationship, each fact row maps to one dimension row, so each fact row is counted once. With many-to-many cardinality, a row on one side can match several rows on the other. A filter can then reach the same fact row by more than one route, and totals become harder to trust.
Common errors
- A dimension slicer has no effect on a measure. The tables have no relationship path, or the relationship is inactive.
- A fact-side slicer does not filter a dimension visual. The cross-filter direction is single, which is the expected behavior.
- A relationship cannot be created as one-to-many. The "one" column contains duplicate values, so the relationship must be many-to-many, or you must remove the duplicates.
Exercise
A model has Products (one row per product) related one-to-many to Sales (many rows per product), with single cross-filter direction. A slicer on Sales[Channel] sits next to a table visual that lists Products[Name]. Does selecting a channel reduce the list of products? Explain using the filter direction.
Show answer
No. The filter from Sales[Channel] would have to travel from the "many" side to the "one" side, and single direction allows only the "one" to "many" path. The product list stays complete. Only measures over Sales respond to the slicer.