OpenBI Docs Buy

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> )
ParameterTypeDescription
columnName1ColumnOne column of an inactive relationship, usually the one on its many side.
columnName2ColumnThe 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 CALCULATE or CALCULATETABLE in its own right, and the two columns must form a relationship of the model; otherwise it is an error. Wrapped in KEEPFILTERS or any other function, it is an error too.
  • The columns may come in either order.
  • RELATED in 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]LitersWith USERELATIONSHIP
Beer15053891505389
Cider301074301074

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.

CROSSFILTER, CALCULATE, RELATED, TREATAS.

Last updated · OpenBI Studio 0.3.74