Sub topic 4
Creating and recognizing inactive relationships
This chapter assumes you know star schemas, one-to-many relationships, and basic CALCULATE. Here you will create a second relationship between Sales and Date, then learn to spot it in the model.
Where inactive relationships come from
Suppose Sales has two date columns, OrderDate and ShipDate. Both should relate to 'Date'[Date]. The model allows only one active relationship between two tables, so only one of the two can be active. The other one must be inactive.
An inactive relationship is a relationship that exists in the model but does not filter anything by default. It stays dormant until a measure turns it on.
Creating the relationship
Follow these steps in Power BI Desktop, in Model view:
- Drag
Sales[OrderDate]onto'Date'[Date]. This creates a many-to-one relationship, and it is active because it is the first one. - Drag
Sales[ShipDate]onto'Date'[Date]. Power BI creates a second relationship and marks it inactive, because an active one already exists between these two tables. - Double-click the new line to open Edit relationship. Confirm that the cardinality is Many to one and that the cross-filter direction is Single.
Check that the relationship has the Make this relationship active box cleared. If you tick it, Power BI makes the ship-date relationship active and turns the order-date relationship off. That swaps the roles instead of adding one.
Recognizing an inactive relationship
In the diagram, an inactive relationship is drawn as a dashed line. An active one is solid. The table below summarizes the differences.
| Property | Active relationship | Inactive relationship |
|---|---|---|
| Line style | Solid | Dashed |
| Filters by default | Yes | No |
| Used by visuals | Yes | No |
| Used by measures | Automatically | Only with USERELATIONSHIP |
Seeing the effect in a report
Create the base measure from earlier chapters. It uses the active relationship.
Sales Amount = SUM ( Sales[SalesAmount] )Place 'Date'[Year] and [Sales Amount] in a table visual. The values are grouped by order date. The inactive ShipDate relationship plays no part. If you drag Sales[ShipDate] into the visual, you get its own values, but the Date table does not filter by it.
This is a common source of confusion. A model can look complete, with two lines to the Date table, while every visual reports by order date only.
Checking relationships without the diagram
On a large model the diagram becomes hard to read. You can list relationships with a DAX query in DAX query view or in DAX Studio:
EVALUATE
INFO.VIEW.RELATIONSHIPS ()The result includes the from and to columns and an indicator of whether each relationship is active. Look for several rows that connect the same pair of tables. Exactly one of them should be active.
Common mistakes at this stage
- Activating the wrong line. Ticking the active box on the ship-date line deactivates the order-date line. Existing visuals then silently change meaning.
- Expecting a second active line. Power BI will not allow it. If you try, it deactivates the other one.
- Relating columns of different data types.
ShipDatemust have the same type as'Date'[Date]. A date with a time part will not match midnight dates, so rows appear as blank. - Forgetting that the inactive line has no effect on visuals. Nothing is broken. The relationship just needs a measure to activate it, which comes next.
What to do next
The inactive relationship is now ready. You can leave it in the model, and it costs almost nothing. The next chapters show how CALCULATE and USERELATIONSHIP activate it for one calculation at a time.
Exercise
A Sales table has OrderDate, ShipDate, and DueDate, and all three are related to 'Date'[Date]. How many of these relationships can be active at once, and how does the diagram show the others?
Show answer
Only one can be active, because a model allows one active relationship between two tables. The other two are inactive and appear as dashed lines. Visuals ignore them until a measure activates them with USERELATIONSHIP.
Exercise
You tick "Make this relationship active" on the ShipDate relationship. What happens to the existing report that uses [Sales Amount]?
Show answer
The OrderDate relationship becomes inactive, and ShipDate becomes the active one. [Sales Amount] now reports by ship date, so existing visuals change meaning without any warning.