RELATEDTABLE DAX Function in Power BI

The RELATEDTABLE DAX function retrieves a table of rows in the related table from the "many" side of a one-to-many relationship that reference the row being iterated.

DAX Syntax RELATEDTABLE(tableName)

The parameter tableName is the name of an existing table (using standard DAX syntax, it cannot be an expression) from which we want to retrieve related rows.

Example: Let’s we have the following “Students Table”.

RELATEDTABLE dax function in Power BI

Let’s we have the following “Branch Table”.

RELATEDTABLE dax function in Power BI

Let’s we have the following data model in the power bi.

RELATEDTABLE dax function in Power BI

Let’s create a new calculated column in the “Branch Table” table.

DAX

Branch specific sum = SUMX(RELATEDTABLE('Students Table'), [10th Marks])

The output of the above dax code is shown below:

RELATEDTABLE dax function in Power BI

Let’s create another column, which counts the number of students in the realted branch of that branch.

DAX

Students Count = COUNTROWS(RELATEDTABLE('Students Table'))

The output of the above dax code is shown below:

RELATEDTABLE dax function in Power BI