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.
Ravindra Bagale's Tip – मराठी
मित्रांनो, बरेच students दुसरी active relationship बनवतात, Power BI ती inactive करतो, आणि मग त्यांना वाटतं relationship "चालत नाही". हे मुद्दाम तसंच आहे: फक्त एकच active path चालतो. Sales by Delivered Date सारख्या measures साठी CALCULATE मध्ये USERELATIONSHIP वापरा. पुन्हा एकदा करून बघा, मग पुढे जा.
Ravindra Bagale's Tip – हिंदी
दोस्तों, बहुत से students दूसरी active relationship बनाते हैं, Power BI उसे inactive कर देता है, और फिर उन्हें लगता है कि relationship "काम नहीं करती". यह जानबूझकर ऐसा है: सिर्फ़ एक active path चलता है. Sales by Delivered Date जैसे measures के लिए CALCULATE के अंदर USERELATIONSHIP इस्तेमाल करो. एक बार फिर करके देखो, फिर आगे बढ़ो.