How to Use RELATEDTABLE in Power BI

Cody Schneider••6 min read

Working with related tables is fundamental in Power BI, but figuring out how to count rows or perform calculations across those relationships can feel tricky. One of the most powerful DAX functions for this is RELATEDTABLE, which lets you navigate from the "one" side of the relationship to the "many" side. This article will show you exactly what RELATEDTABLE does, how it works, and provide practical examples to help you use it effectively in your own reports.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

What Exactly is the RELATEDTABLE Function?

In simple terms, the RELATEDTABLE function returns a table of records from another table that are related to the current row you're on. Think of it as a way to say, "for this specific product, give me a complete list of all the sales associated with it." The key part to remember is that it returns an entire table, not just a single value. This makes it different from its sibling function, RELATED, which navigates a relationship to fetch a single column value from a related record.

  • RELATED: Fetches one value (e.g., gets the Product Name for a specific Sale).
  • RELATEDTABLE: Fetches an entire table of related records (e.g., gets all Sales for a specific Product).

Because it returns a table, you almost always have to wrap it inside another function (like COUNTROWS, SUMX, or AVERAGEX) to get a final, single value that you can display.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

The Syntax

The syntax itself is incredibly simple:

RELATEDTABLE(<TableName>)

You just provide the name of the "many" side table you want to retrieve records from. Power BI’s formula engine handles the rest, using the existing relationships in your data model to filter the table for you.

Before We Begin: A Practical Data Model Example

To demonstrate how RELATEDTABLE works, let’s use a simple and common data model containing two tables: Products and Sales.

1. Products Table: This is our dimension table, or the "one" side of the relationship. Each row represents a unique product.

  • ProductKey (Unique ID)
  • ProductName
  • Category

2. Sales Table: This is our fact table, or the "many" side. It contains every sales transaction.

  • TransactionID
  • ProductKey (Relates back to the Products table)
  • SaleAmount
  • SaleDate

In our data model, there is a one-to-many relationship from Products[ProductKey] to Sales[ProductKey]. This means for one product, there can be many sales.

Use Case 1: Counting Related Sales for Each Product

One of the most frequent uses for RELATEDTABLE is to add context to a dimension table. Let's say you want to quickly see how many individual sales transactions are associated with each product - right in your Products table. This is a perfect job for a calculated column.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Creating the Calculated Column

With the Products table selected in Power BI, create a new calculated column with the following DAX formula:

ProductSalesCount = COUNTROWS(RELATEDTABLE(Sales))

Let’s break down what this formula does for each row in the Products table:

  1. RELATEDTABLE(Sales): For the current product row (let’s say 'Laptop'), Power BI looks at the Sales table. It uses the active relationship on ProductKey to gather a temporary, filtered table containing only the sales records for 'Laptop'.
  2. COUNTROWS(...): This function then takes that temporary table of laptop sales and simply counts the number of rows within it.

The result is a new column named ProductSalesCount in your Products table. For 'Laptop', it might show 150. For 'Mouse', it might show 320. Now you can easily slice, filter, and analyze your products based on how many times they've been sold, without having to summarize the entire sales table.

Use Case 2: Summing Values from a Related Table

Counting is useful, but what about calculating total revenue? Instead of just knowing how many sales a product has, you want to know the total value of those sales. This requires pairing RELATEDTABLE with an "iterator" function like SUMX.

Iterator functions are designed to go row-by-row through a table and perform a calculation. When we feed them a table from RELATEDTABLE, we unlock powerful new analysis.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Calculating Total Revenue Per Product

Let's create another calculated column in our Products table to get the total revenue for each product.

ProductTotalRevenue = SUMX(
    RELATEDTABLE(Sales), 
    Sales[SaleAmount]
)

Here’s the step-by-step for a single product row (e.g., 'Keyboard'):

  1. RELATEDTABLE(Sales): Just like before, this returns a temporary table with all the sales transactions for the 'Keyboard'.
  2. SUMX(..., Sales[SaleAmount]): SUMX is the iterator.

You now have a ProductTotalRevenue column, giving you an immediate view of your top-performing products by revenue. You can use the same pattern with other iterators like AVERAGEX to find the average sale price per product or MAXX to find the largest single sale for each product.

Common Mistakes and Best Practices

As you start using RELATEDTABLE, keep these tips in mind to avoid common frustrations.

  • Don't Forget the Wrapper Function: Using RELATEDTABLE(Sales) by itself in a measure or calculated column will result in an error. This is because it returns a table, not a single value. Always wrap it inside an aggregation function (like COUNTROWS) or an iterator (like SUMX, AVERAGEX, etc.).
  • Understand Row Context: RELATEDTABLE works best in calculated columns because a pre-defined "row context" exists. For each row, the function knows exactly which product you're referring to. Using it in a measure can be more complex, as you need to ensure the correct filter context is providing a single entity to evaluate against.
  • Check Your Relationships: The function depends entirely on the active relationships in your model. If it's not working as expected, the first thing to check is that a valid, single-direction, one-to-many relationship exists between your tables.

Final Thoughts

Mastering RELATEDTABLE is a big step in building more powerful Power BI reports. It gives you the ability to look "down" a one-to-many relationship, letting you count or aggregate data from related records and add valuable context to your dimensions.

While learning DAX is rewarding, we know that spending hours writing formulas and setting up data models isn't for everyone. That’s why we built Graphed. It allows you to connect all your sales and marketing data sources and get these same kinds of insights just by asking questions in plain English - no DAX required. Instead of manually building calculated columns, you can simply ask, "what's the total revenue per product?" and get back an instant, real-time dashboard.

Related Articles