RELATEDTABLE
The rows of a related table that belong to the current row.
Group: Relationships. Compatible with DAX.
Syntax
RELATEDTABLE ( <tableName> )
| Parameter | Type | Description |
|---|---|---|
tableName | Table | A table on the many side of a relationship from the current row's table. |
Returns
Table. The rows of that table that belong to the current row.
Remarks
- In a row context it gives the rows that belong to the current row: for a product, its rows of Sales.
- It works as
CALCULATETABLE ( table ): the current row becomes a filter (context transition), which reaches the table through the relationships. - Without a row context, it gives the table's rows in the current filter context.
- A row with no related rows gets an empty table; COUNTROWS of it is BLANK.
- A table the current row's table does not reach is not narrowed at all: from a product,
RELATEDTABLE ( Places )is every place, as the relationships filter from Places and Products to Sales.
Examples
Rows of two related tables, per product
EVALUATE
ADDCOLUMNS (
Products,
"Sales rows", COUNTROWS ( RELATEDTABLE ( Sales ) ),
"Liters", SUMX ( RELATEDTABLE ( Sales ), Sales[Liters] ),
"Plants", COUNTROWS ( RELATEDTABLE ( Production ) )
)
ORDER BY Products[Product]
| Products[Product] | Products[Category] | Products[Price per liter] | Sales rows | Liters | Plants |
|---|---|---|---|---|---|
| Cider | Cider | 52 | 540 | 301074 | 3 |
| IPA | Beer | 64 | 540 | 331884 | 3 |
| Lettøl | Beer | 30 | 540 | 169179 | 3 |
| Pils | Beer | 38 | 540 | 1004326 | 3 |
A place without sales
The depot has no rows in Sales: its count and its liters are blank.
EVALUATE
SELECTCOLUMNS (
FILTER ( Places, Places[District] = "Alnabru" || Places[District] = "Frogner" || Places[District] = "Storo" ),
"Place", Places[Place],
"Sales rows", COUNTROWS ( RELATEDTABLE ( Sales ) ),
"Liters", SUMX ( RELATEDTABLE ( Sales ), Sales[Liters] )
)
ORDER BY [Place]
| Place | Sales rows | Liters |
|---|---|---|
| Depot Alnabru | (blank) | (blank) |
| Shop Frogner | 144 | 151920 |
| Shop Storo | 144 | 133794 |