Sub topic 10
Ambiguous Paths and Why Power BI Blocks Them
This chapter assumes you can create relationships in the Model view, you know that a filter travels from the one side to the many side by default, and you have seen the cross-filter direction setting. You do not need to know DAX relationship functions beyond reading a simple measure.
What an ambiguous path is
A filter in a Power BI model travels along relationships. An ambiguous path exists when there are two or more routes of active relationships between the same pair of tables. Power BI must pick one route to filter the target table. If both routes were allowed, the same slicer selection could give two different answers, and the engine would have no rule to choose between them.
Power BI does not guess. It prevents the second route from being active. The result is either a refused change or a relationship that is saved as inactive.
A concrete example
Suppose a model has a Sales fact table, a Date dimension, and a Customer dimension. Customer also has a FirstPurchaseDate column, and you relate it to Date.
Date[Date] -> Sales[OrderDate]
Date[Date] -> Customer[FirstPurchaseDate]
Customer[CustomerKey] -> Sales[CustomerKey]A slicer on Date can now reach Sales in two ways:
- Directly: Date to Sales, through
OrderDate. - Indirectly: Date to Customer, through
FirstPurchaseDate, then Customer to Sales.
The first route asks "sales ordered in this period". The second asks "sales from customers whose first purchase was in this period". Both are reasonable questions, and they return different numbers. Only one can be the default.
What Power BI does about it
The behavior depends on where you create the relationship.
- In the Manage relationships dialog or the Properties pane, if the new relationship would create an ambiguous path, Power BI saves it as inactive or shows a message. You can still keep the relationship in the model, but it will not filter anything until a measure activates it.
- When Power BI auto-detects relationships on load, it skips or deactivates any relationship that would create ambiguity.
- If you try to switch a relationship to active, or change a cross-filter direction to both, and that creates ambiguity, Power BI rejects the change and names the tables involved.
The message usually says that the relationship cannot be active because it would introduce ambiguity between two tables. That message is the signal to look for a second path.
Where ambiguity comes from
Ambiguity appears in a few repeatable situations.
| Situation | Why it creates two paths |
|---|---|
| A dimension related to two dates | Date reaches the fact table directly and through the other dimension |
| Two fact tables sharing dimensions with both-direction filters | Filters can pass through one fact table into another dimension and back |
| A dimension chain with both-direction filtering turned on | A filter can travel up and down the chain and reach a table by a second route |
| Role-playing dimensions with several active relationships | Order date, ship date, and due date all relate the same two tables |
The last row is a special case. Two relationships between the same two tables are a direct conflict, so only one can be active. Role-playing dimensions are covered in their own chapter.
How both-direction filtering causes ambiguity
Single-direction relationships in a star schema rarely create ambiguity, because filters only flow outward from dimensions to facts. Ambiguity usually enters when you set a relationship to both directions.
Consider two fact tables, Sales and Returns, both related to Product and Date. With single direction, a Product filter reaches Sales and Returns, and a Date filter reaches both. Each fact table has one route from each dimension.
Now set Product to Sales as both. A filter on Returns can no longer stay put. It reaches Product only if Returns is related to it, but a Date filter can reach Sales, travel up through Product, and then come down into Returns. Date also reaches Returns directly. Two routes from Date to Returns now exist.
Power BI blocks this change. If you need a both-direction filter for a specific question, use CROSSFILTER inside a measure instead. The model stays unambiguous, and only that measure changes behavior.
Customers Who Bought =
CALCULATE (
DISTINCTCOUNT ( Customer[CustomerKey] ),
CROSSFILTER ( Sales[CustomerKey], Customer[CustomerKey], Both )
)Resolving an ambiguous model
Work through these steps in order.
- Open the Model view and look for any table that can be reached from the same source by more than one line. Dashed lines are already inactive.
- Decide which route answers the question that most visuals ask. That relationship stays active.
- Make the other relationship inactive in the Edit relationship dialog by clearing "Make this relationship active".
- Write a measure that activates the inactive route when it is needed.
Total Sales = SUM ( Sales[SalesAmount] )
Sales by Ship Date =
CALCULATE (
[Total Sales],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)USERELATIONSHIP turns the inactive relationship on for the duration of that CALCULATE. While it is on, Power BI deactivates the active relationship between the same two tables, so the evaluation still has a single route.
Other ways to remove ambiguity
Making a relationship inactive is not the only option. Choose by what the data means.
- Duplicate the dimension. Load a second copy of Date, named for its role, such as Ship Date. Each copy gets its own active relationship. This costs more memory and model size, but visuals can use both dates at the same time.
- Remove the redundant relationship. If the
FirstPurchaseDaterelationship is not used, delete it. A calculated column that stores the first purchase year on Customer is simpler. - Return to single direction. If a both-direction setting caused the problem, switch it back and use
CROSSFILTERin the measures that need it. - Restructure the schema. A snowflake that routes one dimension through another often becomes cleaner as a flat dimension.
The trade-off between the first two options is visible in a report. With one Date table and an inactive relationship, a visual shows only one date meaning at a time, and you pick it with a measure. With two Date tables, a matrix can show order month on rows and ship month on columns together.
Checking your result
After resolving an ambiguity, confirm that totals are unchanged and that the filter behaves as intended.
- Place a Date slicer and a card with
[Total Sales]on a page. Select one month. - Compare the card with a manual total from the source data for the same month and the same date column.
- Place the ship-date measure beside it and confirm that it differs when ship dates fall in other months.
- Turn on "Show items with no data" in a table visual to see whether any dimension rows have no matching facts.
Common mistakes
- Switching to both directions "to make a slicer work" without checking for a second route.
- Assuming an inactive relationship will filter. It will not unless a measure activates it.
- Leaving two relationships between the same pair of tables active in the source model after a data refresh and wondering why one is dashed.
- Using
USERELATIONSHIPon a relationship that is already active. It runs, but it changes nothing.
Exercise
A model has Date related to Sales on OrderDate, and Date related to Customer on FirstPurchaseDate. Customer relates to Sales on CustomerKey. Power BI saves the FirstPurchaseDate relationship as inactive. Explain why, and give one way to still report on customers by first purchase date.
Show answer
With both Date relationships active, a Date filter could reach Sales directly through OrderDate or indirectly through Customer. Those are two routes with different meanings, so the path is ambiguous and Power BI keeps only one active. To report by first purchase date, leave the relationship inactive and write a measure that wraps the calculation in CALCULATE with USERELATIONSHIP ( Customer[FirstPurchaseDate], 'Date'[Date] ). Alternatively, load a second date table for first purchase date and relate it with its own active relationship.