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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tiptran
Regular Visitor

Same result with or without RELATEDTABLE

Hi, 

I am referring to the RELATEDTABLE example in https://docs.microsoft.com/en-us/dax/relatedtable-function-dax

 

Internet Sales = SUMX( RELATEDTABLE('InternetSales_USD') , [SalesAmount_USD])

 

Since the 'Product Category' table is linked to 'InternetSales_USD' table in a relationship (1 to many), I found that the following DAX would return the same result as the above: 

 

Internet Sales = SUM( 'InternetSales_USD' [SalesAmount_USD])

 

What is the point of having RELATEDTABLE when the same result could be obtained without it? I know that Tableau does not require explicit command such as RELATEDTABLE to retrieve data from another joined table. You can simply define the relationship (with correct cardinality) and the program would pull the related data for you without any problem.

 

Thanks

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @tiptran 

 

Measures will implicitly apply a CALCULATE around every statement, so if you create a Measure 

Measure = SUM( sales[Sales Amt] )

in reality, this will be  

Measure = CALCULATE( SUM( sales[Sales Amt] ) )

and CALCULATE performs context transition so RELATEDTABLE is not necessary.

 

Please read the link that you have posted explaining RELATEDTABLE and the one that I have and you should be able to understand.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

 

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @tiptran 

 

If you are creating Measure then the result would be the same, however, it would differ when creating a Column, in such scenario RELATEDTABLE or CALCULATE is necessary to preform context transition.
https://www.sqlbi.com/articles/understanding-context-transition/

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn



Thank you, Mariusz. Could you explain why the result is the same if the following formula is used to create a measure and it differs for a new column? 

 

Internet Sales = SUM( 'InternetSales_USD' [SalesAmount_USD])

 

I am guessing that:

  • for a measure, the formula is dynamic enough so that it is responsive to visual's context, i.e. it aggregates sales for each product category (each row)
  • For a column, the formula does not take into account what attributes are present in the visual, and hence blindly aggregating everything from the InternetSales_USD table. 

 

Am I right?

 

Thanks again

Mariusz
Community Champion
Community Champion

Hi @tiptran 

 

Measures will implicitly apply a CALCULATE around every statement, so if you create a Measure 

Measure = SUM( sales[Sales Amt] )

in reality, this will be  

Measure = CALCULATE( SUM( sales[Sales Amt] ) )

and CALCULATE performs context transition so RELATEDTABLE is not necessary.

 

Please read the link that you have posted explaining RELATEDTABLE and the one that I have and you should be able to understand.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.