Hi everyone in this blog we will see the different DAX that are used to define or use the relationship between two tables.
In Power BI there are two type of relationships
1. One to One (1:1)
2. One to Many (1:*)
Now lets look at the DAX functions that we can use with these relationships.
Specifies the relationship to be used in a specific calculation as the one that exists between columnName1 and columnName2.
The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the many side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression.
The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the one side or lookup side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression.
The function returns no value; the function only enables the indicated relationship for the duration of the calculation.
= CALCULATE(SUM(ISales[SalesAmount]), USERELATIONSHIP(Sales[ShippingDate], DateTime[Date]))
USERELATIONSHIP can only be used in functions that take a filter as an argument.
USERELATIONSHIP cannot be used when row level security is defined for the table in which the measure is included.
Returns a related value from another table.
column – The column that contains the values you want to retrieve.
A single value that is related to the current row.
FILTER( ‘Sales_USD’, RELATED(‘Territory'[TerritoryCountry])<>”United States”)
Evaluates a table expression in a context modified by the given filters.
tableName – The name of an existing table using standard DAX syntax. It cannot be an expression.
A table of values.
= SUMX( RELATEDTABLE(‘Sales_USD’)
- The RELATEDTETABLE function changes the context in which the data is filtered, and evaluates the expression in the new context that you specify.
- This function is a shortcut for CALCULATETABLE function with no logical expression.
- This function is not supported for use in Direct Query mode when used in calculated columns or row-level security (RLS) rules.
Hope this helps.