Ravindra BagaleCourses & study guides

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

Friends, many students create a second active relationship, Power BI makes it inactive, and 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. Try it once more, then move on.