Sub topic 3
Why only one relationship between two tables can be active
This chapter assumes you can read a star schema, you know what a one-to-many relationship is, and you can write simple measures with SUM and CALCULATE. The previous chapters showed that one Date table can play several roles for a fact table. This chapter explains the engine rule behind the inactive relationships you will meet in such a model.
The rule in one sentence
A Tabular model, whether in Power BI, Analysis Services, or Excel's Data Model, allows many relationships between the same two tables. At most one of them can be active at a time. Every other relationship between that pair is inactive.
Take a Sales fact table with OrderDate, ShipDate, and DueDate columns, all related to 'Date'[Date]. The model holds three relationships, and the states look like this:
| Relationship | Many side | One side | State |
|---|---|---|---|
| 1 | `Sales[OrderDate]` | `'Date'[Date]` | Active |
| 2 | `Sales[ShipDate]` | `'Date'[Date]` | Inactive |
| 3 | `Sales[DueDate]` | `'Date'[Date]` | Inactive |
An inactive relationship is not deleted or broken. It stays in the model and appears as a dashed line in the diagram view. It does nothing to filter propagation until a calculation asks for it.
Why the engine needs exactly one
Think about what a relationship does. When a filter lands on the Date table, for example 'Date'[Year] = 2024, the engine uses the active relationship to carry that filter to the fact table. It keeps only the Sales rows whose key matches one of the selected dates.
Now suppose all three relationships were active. A slicer on 'Date'[Year] = 2024 would have several valid meanings:
- Sales ordered in 2024.
- Sales shipped in 2024.
- Sales due in 2024.
- Sales where all three dates fall in 2024 (the filters combined with AND).
- Sales where any of the dates falls in 2024 (combined with OR).
Each reading is reasonable, and each gives a different number. The engine has no way to know which one you mean. The model would also need a rule to combine the filters, and that rule would change every number in every report that uses the Date table.
Allowing only one active relationship per pair removes the guesswork. Every filter on the Date table has one meaning: follow the active relationship. If you want a different meaning, you say so explicitly in a measure. That is the job of USERELATIONSHIP, which a later chapter covers.
What the tools do when you add a second relationship
You do not have to manage this state by hand in most cases.
- Power BI Desktop's model view creates the new relationship as inactive when an active one already exists between the same two tables. The Edit relationship dialog shows the Make this relationship active checkbox cleared.
- If you tick that checkbox on a relationship, Power BI Desktop deactivates the one that was active. It asks you to confirm before it does.
- In the Tabular object model (TOM) and in TMDL, each relationship has an
isActiveproperty. Setting it totrueon a second relationship between the same tables produces a validation error when the model is saved or deployed.
You can list the relationships in a model from a DAX query view or from DAX Studio. The following query uses the INFO.VIEW.RELATIONSHIPS function, which exists in recent versions of Power BI Desktop and Analysis Services.
EVALUATE
INFO.VIEW.RELATIONSHIPS ()Look at the IsActive column. In a model like the one above, you should see exactly one TRUE for each pair of tables.
The rule applies to paths, not just direct pairs
The one-active-relationship rule is the visible part of a wider requirement: between any two tables there must be at most one active path. A path can run through intermediate tables. If two different active paths connect the same pair, the engine faces the same ambiguity as before.
Here is a model where this happens. Sales has a direct active relationship to 'Date'. A Budget table also relates to 'Date', and a bidirectional relationship connects Budget to Sales through a shared Product table:
-- Model sketch (relationships, not DAX):
-- 'Date'[Date] 1 --> * Sales[OrderDate] (active)
-- 'Date'[Date] 1 --> * Budget[BudgetDate] (active)
-- Product[ProductKey] 1 --> * Sales[ProductKey] (active)
-- Product[ProductKey] 1 --> * Budget[ProductKey] (active, both directions)A filter on Sales can reach Budget through Product in both directions. A filter on 'Date' can reach Sales directly, and it can also travel 'Date' to Budget to Product to Sales. Two active paths now exist between 'Date' and Sales.
Power BI Desktop detects this when you create or edit a relationship. It either refuses to make the new relationship active, or it shows the message that the relationship would introduce ambiguity between the tables. Analysis Services reports a similar error at deployment, naming the ambiguous paths.
The fix is to remove the cause of the second path, usually by:
- Setting the filter direction on the offending relationship to single.
- Deleting a relationship that you do not need.
- Leaving the relationship in the model but inactive, and activating it only in measures that need it.
The third option is the same mechanism as the role-playing case, applied to a different shape of ambiguity.
The rule is about the model, not the measure
The active or inactive state is a property of the model, so every visual and every measure sees the same default. The model author chooses which role of the Date table is the default. Everything else is opt-in.
This has a practical consequence. In the model above, these two measures behave differently even though neither one mentions a relationship:
Sales Amount = SUM ( Sales[SalesAmount] )
Order Count = COUNTROWS ( Sales )Both follow the active relationship, which here is Sales[OrderDate]. Put 'Date'[Year] on a table visual's rows and you get orders and sales by order year. Nothing in the measure text tells you that. The relationship state decides it.
For this reason, name the default clearly. Many modelers pick the date that most reports use. They then give the alternate-date measures explicit names, such as Sales Amount by Ship Date.
Seeing the effect side by side
A query that evaluates a default measure and an alternate-date measure next to each other makes the active rule visible. The second measure uses USERELATIONSHIP. A later chapter explains it fully, so for now treat it as a way to ask for the inactive relationship on purpose.
Sales Amount by Ship Date =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)EVALUATE
SUMMARIZECOLUMNS (
'Date'[Year],
"Sales by order date", [Sales Amount],
"Sales by ship date", [Sales Amount by Ship Date]
)
ORDER BY 'Date'[Year]This query assumes your Date table has a Year column. Each row of the result is one year. The two measure columns differ because the same year selects a different set of Sales rows in each. An order placed in December and shipped in January lands in different years in the two columns. The grand total of the two columns is normally the same, because every sale has one order date and one ship date.
That last point is worth checking in your own data. If the totals differ, some rows have a ship date that is blank or falls outside the Date table. Those rows drop out of the year breakdown in the ship-date column. The pitfalls chapter returns to this.
What inactive does and does not turn off
Learners often assume an inactive relationship disappears. It does not, and the difference matters when you troubleshoot.
| Behavior | With the relationship inactive |
|---|---|
| Filters from `'Date'` reach `Sales` through it | No |
| It is shown in the diagram view | Yes, as a dashed line |
| `USERELATIONSHIP` can activate it inside `CALCULATE` | Yes |
| It counts as an ambiguous path | No |
| `RELATED ( 'Date'[Year] )` in a `Sales` calculated column uses it | No, `RELATED` follows the active relationship only |
| Row-level security filters on `'Date'` flow through it | No |
The last row surprises people. If you apply a row-level security rule to the Date table, it reaches the fact table only through the active relationship. A user restricted to 2024 is restricted by order date. Their ship-date measures can still return sales from other years, unless you also restrict the fact table.
Dealing with the single-active constraint in practice
You have four options when a model has several date roles. The rest of the tutorial covers them in detail.
- Keep one active relationship and activate the others per measure with
USERELATIONSHIP. - Create a separate Date table for each role, each with its own active relationship.
- Use a calculation group so that one selector switches the date role for all measures.
- Restructure the fact table so each row has one date and a role column. This is rarely worth the cost.
The constraint is the reason all of these options exist. If the engine allowed several active relationships, you would not need them.
Common misunderstandings
- "Inactive means broken." An inactive relationship is valid. It just waits to be activated.
- "I can make two active if the columns are different." The rule is about the pair of tables, not the columns. Different columns on the same two tables are still the same pair.
- "The first relationship I create is the best default." Power BI makes the first one active, but it does not know which role your reports need most. Review it.
- "
USERELATIONSHIPadds a second active relationship." It does not. Inside theCALCULATE, it swaps which relationship is active for that pair. The other one is ignored for that calculation.
Exercise
A model has Sales[OrderDate] and Sales[ShipDate], both related to 'Date'[Date]. A colleague says they will make both relationships active so that a Year slicer on the Date table filters sales by order year and ship year at once. Give two reasons the engine does not allow this. Then say what the colleague should do to report sales by ship year without changing the default.
Show answer
First, the filter from 'Date'[Year] would have several valid meanings: order year, ship year, both combined with AND, or either combined with OR. Each gives a different result and the engine has no way to pick one. Second, the same ambiguity would affect every measure that uses the Date table, so every existing report number would change. Power BI Desktop makes the second relationship inactive, and a model with two active relationships between the same tables fails validation. To report by ship year, the colleague should keep Sales[OrderDate] as the active relationship and write a measure that wraps [Sales Amount] in CALCULATE with USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ). The default stays on order date.
Exercise
Your model has an active relationship from 'Date' to Sales. You then add a bidirectional relationship between Budget and Product while Budget also relates to 'Date'. Power BI Desktop reports ambiguity. What does that tell you, and what are three ways to resolve it?
Show answer
There are now two active paths between 'Date' and Sales: the direct relationship and the one through Budget and Product. The engine cannot tell which path a Date filter should follow. You can set the filter direction on the offending relationship to single, delete a relationship you do not need, or keep the relationship but make it inactive and activate it only in measures that need it.