Sub topic 2
One-to-Many: The Standard Relationship
Assume you know how to load tables into Power BI, create a basic measure, and use visuals and slicers. This chapter focuses on how relationships control filtering.
One-to-Many Relationships
A one-to-many relationship connects one row in a lookup table to many rows in another table. In a star schema, the lookup table is usually a dimension, such as Product, and the other table is usually a fact table, such as Sales.
For example, one product can appear in many sales rows:
Product[ProductKey]is the one side.Sales[ProductKey]is the many side.- Both columns contain matching product keys.
- The product key in
Productshould be unique.
Power BI normally represents this relationship as 1:*. The dimension stores descriptive information. The fact table stores events or measurements.
Single and Both Cross-Filter Directions
Cross-filter direction controls how a filter moves across a relationship.
With Single direction, filters move from the one side to the many side. A product slicer can filter sales, which is the usual star-schema behavior.
With Both direction, filters can move from either table. A filter on Sales can also filter Product.
| Direction | Typical use | Main concern |
|---|---|---|
| Single | Dimension filters fact table | Limited reverse filtering |
| Both | Special modeling cases | Ambiguous paths and unexpected totals |
How a Filter Travels
Suppose a report contains a Product[Category] slicer. Selecting “Bikes” filters the matching rows in Product. The relationship sends those product keys to Sales. Measures such as total sales then calculate only over sales rows for those products.
When Both-Direction Filtering Helps
Both-direction filtering can help when a dimension must respond to filters from a related fact table, or when a carefully designed bridge table connects two dimensions. It can also make a slicer show only values that have matching transactions.
Risks include circular filtering, ambiguous routes between tables, slower models, and totals that change unexpectedly. If two paths connect the same tables, Power BI may block the relationship or produce confusing results.
Exercise
A Product slicer does not filter Sales. What should you check first?
Show answer
Check that Product[ProductKey] is unique, Sales[ProductKey] has the matching data type and values, and the relationship is active with Single filtering from Product to Sales.