USERELATIONSHIP
As a filter of CALCULATE, uses an inactive relationship between two columns for the calculation.
Group: Relationships. Compatible with DAX.
Syntax
USERELATIONSHIP ( <columnName1>, <columnName2> )
| Parameter | Type | Description |
|---|---|---|
columnName1 | Column | One column of an inactive relationship, usually the one on its many side. |
columnName2 | Column | The relationship's other column. |
Returns
Filter. No value of its own: it makes the relationship the active one for the CALCULATE it is in.
Remarks
- Between two tables only one relationship can be active, the one filters follow; a model may hold more that are inactive. Sales with an order date and a delivery date, both related to one date table, is the usual case. USERELATIONSHIP uses an inactive one for one calculation, and the active one between the same tables rests meanwhile.
- It works only as a filter of
CALCULATEorCALCULATETABLEin its own right, and the two columns must form a relationship of the model; otherwise it is an error. Wrapped inKEEPFILTERSor any other function, it is an error too. - The columns may come in either order.
RELATEDin an iteration inside that CALCULATE follows the relationship it activated.- The Example Brewery has no inactive relationship. The examples show what can be shown there: naming the active relationship changes nothing, and two columns without a relationship are an error.
Examples
The active relationship named
EVALUATE
SUMMARIZECOLUMNS (
Products[Category],
"Liters", [Liters sold],
"With USERELATIONSHIP", CALCULATE ( [Liters sold], USERELATIONSHIP ( Sales[Product], Products[Product] ) )
)
ORDER BY Products[Category]
| Products[Category] | Liters | With USERELATIONSHIP |
|---|---|---|
| Beer | 1505389 | 1505389 |
| Cider | 301074 | 301074 |
Two columns without a relationship
Sales[Month] and Periods[Month] are not related in the Brewery, so there is nothing to activate.
EVALUATE
ROW ( "Liters", CALCULATE ( [Liters sold], USERELATIONSHIP ( Sales[Month], Periods[Month] ) ) )
Result: an error.
Where a relationship is missing altogether, TREATAS applies one column's values to another for the calculation.