USERELATIONSHIP in DAX — Use Inactive Relationships
USERELATIONSHIP activates an inactive model relationship inside CALCULATE for that measure only — the standard fix when you need sales by OrderDate and by DeliveredDate without two active paths between the same tables.
Chala mitrano! Model view shows a solid line and a dashed line — students think the dashed one is “broken”. Why? Power BI allows one active path. How? We keep OrderDate active, then write a DeliveredDate measure with USERELATIONSHIP on fictional FreshBasket dates. Clean close for this batch.
Quick answer
Vertical path:
- Model view: active
Sales[OrderDate] → Date[Date]. - Inactive:
Sales[DeliveredDate] → Date[Date](dashed). - Normal sales use the active path.
Sales by Delivery = CALCULATE ( [Total Sales], USERELATIONSHIP ( Sales[DeliveredDate], 'Date'[Date] ) ).- Compare both measures under the same Year slicer.
- Do not fight Desktop for two active relationships — use measures.
CALCULATE (
[Total Sales],
USERELATIONSHIP ( Sales[DeliveredDate], 'Date'[Date] )
)
Why USERELATIONSHIP, rows in / number out
| Order ID | OrderDate | DeliveredDate | Amount | City |
|---|---|---|---|---|
| A | 5 Jan | 8 Jan | 100 | Mumbai |
| B | 28 Jan | 2 Feb | 40 | Mumbai |
| C | 10 Feb | 12 Feb | 80 | Nashik |
- Why: one rupee can sit in January by order date and February by delivery date.
- Active path = OrderDate. January OrderDate filter: rows A + B. Number out: 140 (Mumbai’s January orders).
- Delivery measure activates the DeliveredDate path. January delivery filter: only A (100). Order B delivered in February.
- Same
[Total Sales]expression. Different relationship. Different month story. - Titles must say which clock you used.
Model view: one active path (solid); a second date path is often inactive (dashed) until a measure activates it.
मित्रांनो — Model view: one active path (solid); a second date path is often inactive (dashed) until a measure activates it.
मित्रों — Model view: one active path (solid); a second date path is often inactive (dashed) until a measure activates it.
What do I need before this guide?
- A Date table and RELATED basics mindset.
- Course: USERELATIONSHIP · Relationships.
Before and after (look at the tables first)
Before
आधी (Before)
पहले (Before)
After
नंतर (After)
बाद में (After)
Inactive is by design
- Two date columns on Sales both want Date.
- Only one relationship stays active.
- The other waits for USERELATIONSHIP in a measure.
- Not an error — a modelling rule.
Shop analogy: one wall calendar is the “order clock”. A second calendar is the “delivery clock”. Only one is pinned as default. USERELATIONSHIP borrows the delivery calendar for one question.
USERELATIONSHIP in CALCULATE
Pattern: CALCULATE ( [Total Sales], USERELATIONSHIP ( Sales[DeliveredDate], 'Date'[Date] ) ).
मित्रांनो — Pattern: CALCULATE ( [Total Sales], USERELATIONSHIP ( Sales[DeliveredDate], 'Date'[Date] ) ).
मित्रों — Pattern: CALCULATE ( [Total Sales], USERELATIONSHIP ( Sales[DeliveredDate], 'Date'[Date] ) ).
Sales by Delivery =
CALCULATE (
[Total Sales],
USERELATIONSHIP (
Sales[DeliveredDate],
'Date'[Date]
)
)
- Activates the delivered-date path for this calculation.
- Year/Month filters then apply along delivered dates.
- Active OrderDate path remains the default for other measures.
Business question first
Business question first: “sales by order date” vs “sales by delivered date” — then activate the matching relationship.
मित्रांनो — Business question first: “sales by order date” vs “sales by delivered date” — then activate the matching relationship.
मित्रों — Business question first: “sales by order date” vs “sales by delivered date” — then activate the matching relationship.
- “When did customers order?” → OrderDate (active).
- “When did we deliver?” → DeliveredDate via USERELATIONSHIP.
- Same rupees can sit in different months on the two timelines.
- Titles must say which clock you used.
Mistakes and calm fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| “Relationship doesn’t work” | It is inactive | Use USERELATIONSHIP in the measure |
| Blank measure | Wrong columns paired | Match DeliveredDate to Date[Date] |
| Same as normal sales | Still on active path | Confirm USERELATIONSHIP arguments |
| Model error fighting two actives | Tried to activate both | Keep one active; measure the rest |
Ghabru naka 😅 — dashed lines are invitations, not failures.
Ravindra Bagale's Tip
Many students create a second active relationship, get a warning, and delete the path. Better story: leave it inactive, activate with USERELATIONSHIP when the question is delivery-dated. Pay attention!
Ravindra Bagale's Tip – मराठी
बरेच students दुसरा active relationship बनवतात, warning येते, आणि path delete करतात. चांगली गोष्ट: inactive ठेवा, delivery-dated प्रश्न असेल तेव्हा USERELATIONSHIP ने activate करा. लक्ष ठेवा!
Ravindra Bagale's Tip – हिंदी
बहुत students दूसरा active relationship बनाते हैं, warning आती है, और path delete कर देते हैं. बेहतर कहानी: inactive छोड़ो, delivery-dated सवाल हो तो USERELATIONSHIP से activate करो. ध्यान रखो!
Practice task
- Confirm active vs inactive date paths in Model view.
- Create Sales by Delivery with USERELATIONSHIP.
- Month matrix: normal Sales vs Sales by Delivery (January order 140 vs delivery 100 on the sample idea).
- Find a month where they differ; explain why.
- Rename visuals “by order date” / “by delivered date”.
Samajla ka? One active path; USERELATIONSHIP wakes an inactive one inside CALCULATE. Guides 11–30 classroom rewrite complete for this batch. Aata pudhe jaauya.
Frequently asked questions
What does USERELATIONSHIP do?
Inside CALCULATE, it activates an inactive relationship for that evaluation only.
Why are relationships inactive?
Power BI allows one active relationship path between two tables; extra paths are inactive by design.
Can I make both active?
Not between the same two tables at once. Use USERELATIONSHIP in measures for the alternate path.
Blank results?
Wrong columns paired, missing dates, or relationship not actually defined in the model.
ROLE-playing dates?
Order vs ship vs deliver dates are classic role-playing date scenarios — this pattern is the standard fix.
Course lessons?
USERELATIONSHIP in DAX and relationships in data modelling.