RELATED Function
Description:
The RELATED function returns a related value from another table.
Return Value:
RELATED returns a single value that is related to the current row.
Syntax:
RELATED( <ColumnName> )
- Description of the parameter:
PARAMETER |
DESCRIPTION |
---|---|
ColumnName |
The column that contains the values you want to retrieve |
Example:
In our data model, the Sales table is related to the Geography table. We want to calculate the sales amount for Germany. To do so, we can use the formula down below:
Germany_SalesAmount =
SUMX(
FILTER(
Sales,
RELATED(Geography[RegionCountryName])="Germany"
)
,Sales[SalesAmount]
)
The RELATED function requires that a relationship exists between the current table and the table with related information. If a relationship does not exist, you must create a relationship.
RELATEDTABLE Function
Description:
The RELATEDTABLE function evaluates a table expression in a context modified by the given filters.
Return Value:
RELATEDTABLE returns a table of values.
Syntax:
RELATEDTABLE( <tableName> )
- Description of the parameters:
PARAMETER |
DESCRIPTION |
---|---|
TableName |
The name of an existing table using standard DAX syntax |
Example:
We want to add a calculated column to the Product Category table, that calculates the Sales Amount for each Product Category.
By adding a new column in the table, we can use the following formula:
SalesAmount_Column =
SUMX(
RELATEDTABLE(Sales)
,Sales[SalesAmount]
)
Related Video: