Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
ajit_singh
Frequent Visitor

Using RELATED() in measure when there is no relationship

The example is from the book "The Definitive Guide to DAX - 2nd Ed - Alberto Ferrari, Marco Russo", Chapter 15, example 15-5.

The table "Advertised Brands" table has not relationship with Product or Date.

 

image-20210210100522105.png

 

From the definition of RELATED() at https://dax.guide/related/

The RELATED function requires that a relationship exists between the current table and the table with related information. The argument specifies a column reference, and the function follows a chain of one or more many-to-one relationships to fetch the value from the specified column in the related table. If a relationship does not exist, RELATED raises an error.

The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value.

How RELATED() works in below measure when there is no relationship?

 

Advertised Brand Sales = 
SUMX (
  FILTER (
      Sales,
      CONTAINS (
          'Advertised Brands',
          'Advertised Brands'[Brand], RELATED ( 'Product'[Brand] ),
          'Advertised Brands'[Calendar Year], RELATED ( 'Date'[Calendar Year] ),
          'Advertised Brands'[Month], RELATED( 'Date'[Month] )
      )
  ),
  Sales[Quantity] * Sales[Net Price]
)

And measure gets data for each brand where the [Sales Amount] measure doesn't get for each brand?

 

image-20210210100620845.png

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

the row context of Function RELATED comes form FILTER's 1st parameter, i.e. table of Sales, which has a many to one relationship with table Dates

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

the row context of Function RELATED comes form FILTER's 1st parameter, i.e. table of Sales, which has a many to one relationship with table Dates

Crisp, concise and clear, thank you 🙏

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.