13. DAX: Data Analysis Expressions
13.12 USERELATIONSHIP
Activates an inactive relationship for one calculation. It only works inside CALCULATE (or CALCULATETABLE).
Sales by Delivered Date =
CALCULATE([Total Sales], USERELATIONSHIP(Orders[Delivered Date], 'Date'[Date]))
Orders Delivered (by delivery date) =
CALCULATE([Delivered Orders], USERELATIONSHIP(Orders[Delivered Date], 'Date'[Date]))
Put Date on the axis and show [Delivered Orders] and [Orders Delivered (by delivery date)] side by side: the small differences come from orders placed just before midnight and delivered the next day.
Ravindra Bagale's Tip
Mitrano, khup students create a second active relationship and Power BI makes it inactive, then they think the relationship "doesn't work". That is by design: only one active path is allowed. Use USERELATIONSHIP inside CALCULATE for measures such as Sales by Delivered Date. Punha ekda karun bagha, mag pudhe jaa.