Power BI

How to Use RELATED() and RELATEDTABLE() in Power BI DAX

How to Use RELATED() and RELATEDTABLE() in Power BI DAX

Table of Contents

Introduction

When working with multiple tables in Power BI, the understanding of RELATED() and RELATEDTABLE() is essential for retrieving and analyzing data across relationships.

In this blog post, we will see how to use RELATED() and RELATEDTABLE() in Power BI DAX.

Learn more about DAX as a formula language in blog: DAX in Power BI: As a formula language

Using RELATED()

What is RELATED()?

RELATED() is a DAX function that returns a related value from another table. It takes value from the one side of the one-to-many relationship and populates it to the many side of the relationship.

RELATED() Table
Figure 1: RELATED() Table

In simpler words:
It lets you look up a single value from a related table.

RELATED() Use Case: Bringing Price List to Sales Table

To follow this step-by-step guide, you can use the Power BI file given at the end of this Blogpost. To use RELATED() for bringing the list price value from the Product table into the Sales table: 

  1. Right click on the Sales table in the Fields Pan.
  2. Click on New Column.

Column tools open.

  1. Type the following formula in the formula bar.
Creating Cloumn using RELATED() function
Figure 2: Notice that the IntelliSense detects that currently List Price does not exist in Sales Table. So, IntelliSense does not give option to select a column from the Product table. We will use RELATED() function to activate the relationship.

4. Type RELATED in the formula bar after equal to (=).

5. Select the List Price from the Product table.

Your DAX expression should look like the expression below.

Current List Price (CC) =
RELATED ( ‘Product'[List Price] )

In this Expression a calculated column with each row containing the respective List Price from the Product table has been created.

6. Click on Table View in the left Ribbon.

7. Click on Sales table in the Fields.

Power BI automatically maps each Sales row to the corresponding Product List Price using relationships, adding the price as a calculated column in the Sales table.
Figure 3: Power BI automatically maps each Sales row to the corresponding Product List Price using relationships, adding the price as a calculated column in the Sales table.

What is Happening Here?

  • Every row in the Sales table gets the corresponding List Price from the Product table.
  • Power BI uses the relationship to automatically match rows.

Result: A new column in Sales with product prices.

Key Insight

In this example, RELATED() works because:

  • There is a many-to-one relationship.
  • Each Sales row corresponds to exactly one Product.

Using RELATEDTABLE()

What is RELATEDTABLE()?

The RELATEDTABLE() function changes the context in which the data is filtered and evaluates the expression in the new context that you specify. It takes values from the many sides of the one-to-many relationship and populates the one side of the relationship.

RELATEDTABLE() Table
Figure 4: RELATEDTABLE() Table

RELATEDTABLE() Use Case: Counting Sales per Customer

To use the RELATEDTABLE() function for calculating the number of sales in Customer Table:

  1. Right click on the Customer table in the Fields pan.
  2. Click on New column.

Column tools open.

  1. Type the following formula in the formula bar and press Enter.

Number of Sales (CC) =
COUNTROWS ( Sales )

In this Expression, the rows in the Sales table have been counted.

  1. Click on Data tab in the left Ribbon.
  2. Click on Customer table in the Fields pan.
Customer table
Figure 5: As you can see, row context does not follow relationships. RELATEDTABLE() allows us to traverse the chain of relationships.

6. Click on the Number of Sales (CC) column.

   Column tool box appears containing the formula bar.

7. Add RELATEDTABLE() before the sales in the formula.

8. Your DAX expression should look like the expression below.

    Number of Sales (CC) =
    COUNTROWS ( RELATEDTABLE ( Sales ) )

In this Expression the related number of rows from the sales table are counted based on the incoming filter context.

Number of Sales (CC) using RELATEDTABLE() Column
Figure 6: Notice the change of values in the Number of Sales (CC) column.

What’s Happing Here?

  • RELATEDTABLE(Sales) returns only the sales related to each customer.
  • COUNTROWS() counts those filtered rows.

Result: Each customer now shows their actual number of transactions.

Key Insight

  • RELATEDTABLE() uses filter context.
  • It helps traverse relationships from one → many.

RELATED() vs. RELATEDTABLE()

RELATED() and RELATEDTABLE() are the two functions used to traverse one-to-many relationship in DAX. The few key differences between the two functions are:

 

RELATED()

RELATEDTABLE()

Input Argument

Column name

Table name

Output

Single value from the current row

A table of values

Takes values from

One side of relationship

Many sides of the relationship

Populates

Many sides of the relationship

One side of relationship



When to Use RELATED() and RELATEDTABLE()

  1. You can use RELATED() when you need a single value.

For example: Price, category, customer name.

2. You can use RELATEDTABLE() when you need to analyse multiple rows.

For example: Count, sum, or filter related records.

Conclusion

Working with relationships in Power BI requires an understanding of RELATED() and RELATEDTABLE(). RELATEDTABLE() enables you to work with several related rows for aggregation, whereas RELATED() helps you retrieve a single item from a related table. Gaining familiarity in these functions can significantly boost your data modelling and DAX skills.

Want to learn how to write DAX Queries? Check out our post: Learn How to Write DAX Queries in DAX Studio Using Query Builder

FAQs

RELATED() and RELATEDTABLE() are DAX functions that help you work with table relationships. RELATED() returns a single value from the one side of a relationship, and RELATEDTABLE() returns multiple related rows from the many side.

RELATED() is used when you want to pull in a value from a related table into another table, e.g. the price of a product, or the name of a customer.

Use RELATEDTABLE() when you want to work with multiple related rows, especially for aggregations such as counting sales, summing values or filtering related records.

Further Learning and Resources

To learn more about Power BI, check out our courses here: 

Want to learn how Microsoft 365 Copilot transforms everyday work with AI? Check out our Course:  

Want to learn more about Power BI and how to make reports more efficiently? 

Power BI training in Australia: We offer comprehensive training sessions across various cities, including: 

Ready to enhance your Power BI skills? Sign up for our training courses and explore our wide range of resources designed to elevate your data analytics capabilities.  

Contact Us: Make an enquiry about our Power BI courses and find the proper training for you. 

Leave a Reply

Your email address will not be published. Required fields are marked *