Sub topic 14
One-to-one relationships
This chapter assumes you can create a relationship in the Model view and that you know what a key column is. It also assumes you have read the chapter on one-to-many relationships.
What a one-to-one relationship is
In a one-to-one relationship, each value in the key column of one table matches at most one row in the other table, and the reverse is also true. Both key columns must hold unique values.
Power BI shows this as 1 on both ends of the line in the Model view. It also sets the cross-filter direction to Both automatically. A filter on either table therefore reaches the other.
When you see one in a model
A one-to-one relationship is usually a sign that one entity was split across two tables. Common causes are:
- A source system stores core customer fields in one table and optional details in another, both keyed by CustomerID.
- A query loaded a wide table in two parts.
- A table of sensitive columns was separated from a public table.
Why it is often better to merge
Two tables that describe the same entity add a relationship to maintain, add a table to the field list, and force report authors to choose which table holds a field. Because the direction is both, the pair also behaves as a single table and gains nothing from being separate.
In most cases, combine them in Power Query with Merge Queries. Use a left outer join on the key, expand the columns you need, and disable loading of the second query.
The table below summarizes when to keep the relationship.
| Situation | Recommendation |
|---|---|
| Both tables describe the same entity and are always used together | Merge them in Power Query |
| One table is very wide and rarely used, and you want a tidy field list | Keep them separate |
| Different refresh schedules or security rules apply to each table | Keep them separate |
Creating the relationship
- Open the Model view.
- Drag
Customer[CustomerKey]ontoCustomerDetail[CustomerKey]. - In the dialog, confirm that the cardinality reads One to one (1:1).
- Select Save.
If either column contains duplicates, Power BI detects the many side and proposes Many to one or Many to many instead. Treat that as a data check. A duplicate key in a table you expected to be unique often points to a load problem.
Behavior to watch
- The relationship is filtered in both directions, so a slicer on
CustomerDetailnarrowsCustomerand anything related toCustomer. - If the detail table is missing a key, Power BI still keeps the customer row, but the detail columns show blank for it.
- When you chain a one-to-one table onto a dimension that also has one-to-many relationships, the both-direction filter can create ambiguous paths. The ambiguity chapter covers how to spot and fix them.
Exercise
You load Employee and EmployeeHR, and both have a unique EmployeeID. You create a relationship between them and Power BI shows 1 on both ends with filtering in both directions. What is the cardinality, and what would you consider doing instead of keeping the relationship?
Show answer
The cardinality is one-to-one. Unless the tables need separate refresh schedules, security, or a tidy field list, merge them into a single table in Power Query using Merge Queries on EmployeeID, because they describe the same entity.