USERELATIONSHIP DAX Function (Relationships management)

Specifies an existing relationship to be used in the evaluation of a DAX expression. The relationship is defined by naming, as arguments, the two columns that serve as endpoints.

Syntax

USERELATIONSHIP ( <ColumnName1>, <ColumnName2> )
Parameter Attributes Description
ColumnName1

Foreign (or primary) key of the relationship.

ColumnName2

Primary (or foreign) key of the relationship.

Return values

The function returns no value; the function only enables the indicated relationship for the duration of the calculation.

Remarks

USERELATIONSHIP can only be used in functions that take a filter predicate as an argument, for example: CALCULATE, CALCULATETABLE, CLOSINGBALANCEMONTH, CLOSINGBALANCEQUARTER, CLOSINGBALANCEYEAR, OPENINGBALANCEMONTH, OPENINGBALANCEQUARTER, OPENINGBALANCEYEAR, TOTALMTD, TOTALQTD and TOTALYTD functions.

USERELATIONSHIP uses existing relationships in the model, identifying relationships by their ending point columns.

In USERELATIONSHIP, the status of a relationship is not important; that is, whether the relationship is active or not does not affect the usage of the function. Even if the relationship is inactive, it will be used and overrides any other active relationships that might be present in the model but not mentioned in the function arguments.

An error is returned if any of the columns named as an argument is not part of a relationship or the arguments belong to different relationships.

If CALCULATE expressions are nested, and more than one CALCULATE expression contains a USERELATIONSHIP function, then the innermost USERELATIONSHIP is the one that prevails in case of a conflict or ambiguity.

Related functions

Other related functions are:

Last update: Dec 13, 2018   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

MSDN documentation: https://msdn.microsoft.com/en-us/query-bi/dax/userelationship-function-dax

DAX Conventions
Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Deprecated

This parameter is deprecated and its use is not recommended.

Contribute

Want to improve the content of USERELATIONSHIP? Did you find any issue? Please, report it us!
All submissions will be evaluated for possible updates of the content.