All DAX Functions

The RELATEDTABLE() Function: Fetching Sub-Tables Across Relationships

Return related fact rows from the many side of a relationship.

On this page

Overview

The RELATEDTABLE function returns a table of all rows on the "many" side of a relationship that correspond to the current row on the "one" side. It is the inverse of RELATED: instead of fetching a single value, it returns an entire related table.

It is especially useful when you need to count, sum, or average child records per parent—such as orders per customer—without building a separate calculated column.

Syntax

DAX Syntax
RELATEDTABLE(<table>)
  • <table>: The table on the "many" side of an active one-to-many relationship.
  • Must be evaluated in row context on the "one" side table (e.g., inside SUMX over Customers).

Example & Dataset

A Customers dimension linked to an Orders fact table (one customer, many orders):

Customers

CustomerIDCustomerName
C01Alice
C02Bob
C03Carol

Orders

OrderIDCustomerIDOrderAmount
O01C01120
O02C0180
O03C02200
O04C0150
O05C0375

The DAX Code

To show how many orders each customer has placed, iterate over Customers and count rows in the related Orders table:

Order Count per Customer (Table Visual)
Customer Order Count =
SUMX(
    Customers,
    COUNTROWS( RELATEDTABLE(Orders) )
)

Expected Output Visual

Dragging CustomerName and a per-customer measure into a Table visual yields:

Output Table Visual

CustomerNameOrders (via RELATEDTABLE + COUNTROWS)
Alice3
Bob1
Carol1
Grand Total (if summed)5

Why Did This Output Happen?

For each customer row, RELATEDTABLE(Orders) returns only the orders matching that CustomerID. COUNTROWS counts them: Alice has O01, O02, O04 (3); Bob has O03 (1); Carol has O05 (1). The SUMX wrapper aggregates these per-customer counts when used in a total, or displays them row by row in a table visual filtered to each customer.