Relationships
Learn how Power BI relationships connect fact tables and dimension tables to create interactive data models.
Relationships
Relationships define how tables connect inside a Power BI data model.
They allow filters and calculations to move between tables.
In a star schema:
- Dimension tables filter fact tables.
- Fact tables store the business events.
- Relationships connect the two.
Example:
DimDate
|
|
DimCustomer --- FactSales --- DimProduct
|
|
DimStoreWithout relationships, Power BI treats tables as separate datasets.
How Relationships Work
A relationship connects two tables using matching columns.
Example:
DimProduct
ProductKey
ProductName
Categoryconnects to:
FactSales
ProductKey
Quantity
SalesAmountThe shared column:
ProductKeycreates the relationship.
One-to-Many Relationships
The most common Power BI relationship is:
Dimension Table
|
| 1 : Many
|
Fact TableExample:
DimProduct
ProductKey | ProductName
-----------|------------
1001 | Tire A
1002 | Tire BFact table:
FactSales
ProductKey | SalesAmount
-----------|------------
1001 | 250
1001 | 400
1002 | 180One product can have many sales records.
Relationship Cardinality
Cardinality describes how rows match between tables.
Power BI supports:
One-to-Many (1:*)
Most common relationship.
Example:
DimCustomer
|
| 1 : Many
|
FactSalesOne customer can have many sales transactions.
One-to-One (1:1)
Both tables contain unique values.
Example:
Employee
|
| 1 : 1
|
EmployeeDetailsThis is less common in analytical models.
Many-to-Many (:)
Both tables contain duplicate values.
Example:
Customers
Customer A
Customer B
Products
Product A
Product BMany-to-many relationships can create:
- Ambiguous filtering
- Unexpected calculations
- Complex DAX
Use carefully.
Filter Direction
Relationships control how filters travel.
Example:
DimProduct
|
v
FactSalesSelecting:
Category = "Off Road"filters:
DimProduct
↓
FactSalesThe result:
Only Off Road sales are calculated.Single Direction Filtering
Recommended for most star schemas.
Example:
DimProduct
|
v
FactSalesFilters move from dimension to fact.
Benefits:
- Easier to understand
- Better performance
- Fewer ambiguous paths
Both Direction Filtering
Power BI allows filters to travel both directions.
Example:
DimProduct
↕
FactSalesUse carefully.
Problems can include:
- Circular relationships
- Ambiguous filter paths
- Incorrect results
Most enterprise models avoid unnecessary bidirectional filtering.
Active and Inactive Relationships
A table can contain multiple relationships.
Example:
FactSales
OrderDateKey
ShipDateKeyBoth connect to:
DimDateHowever, only one relationship can be active.
Example:
FactSales[OrderDateKey]
Active
DimDate[DateKey]The other relationship becomes inactive.
Use DAX to activate inactive relationships:
Sales by Ship Date =
CALCULATE(
[Total Sales],
USERELATIONSHIP(
FactSales[ShipDateKey],
DimDate[DateKey]
)
)Relationship Best Practices
Follow these guidelines:
- Use one-to-many relationships whenever possible.
- Filter from dimensions to facts.
- Avoid unnecessary bidirectional filtering.
- Use clear key columns.
- Maintain a star schema structure.
Recommended:
DimCustomer
|
|
FactSales
|
|
DimProductAvoid:
FactSales
|
|
FactInventoryInstead:
DimProduct
|
FactSales ---+
|
FactInventoryCommon Relationship Mistakes
Missing Relationships
Symptoms:
- Incorrect totals
- Filters do not work
- Visuals show unexpected results
Incorrect Cardinality
Example:
Setting:
Many-to-Manywhen the model should be:
One-to-Manycan create calculation problems.
Multiple Filter Paths
Example:
DimCustomer
|
FactSales
|
DimProductplus another path between tables can create ambiguity.
Relationship Checklist
A good Power BI model should have:
- Clear relationships
- Proper cardinality
- Dimension-to-fact filtering
- Minimal bidirectional relationships
- Consistent key columns
Next Steps
Continue learning Power BI data modeling:
Advanced Topics: