cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

RELATED function - how it works

i was trying to use RELATED function between two tables with Many to 1 relationship. It looks like it only works on the

'Many' side.  Like i can only add related columns to 'Many' table from '1' side  but not the other way around.  I want to add columns to '1' side from 'Many' table. it does not work.

Is it by design or am i missing anything...

1 ACCEPTED SOLUTION

Accepted Solutions
OwenAuger Super Contributor
Super Contributor

Re: RELATED function - how it works

@reddy_powerbi 

That's right, RELATED (which can only be used in a row context) follows a chain of one or more many-to-one relationships to retrieve a column value on the one-side.

 

Since RELATED returns a scalar value, isn't able to retrieve a value on the many-side, since there could be multiple values of a given column on the many-side.

 

One way you could lookup a single value on the many-side is using a function like FIRSTNONBLANK to return the "minimum" value.

Something like

Min Value on many side =
FIRSTNONBLANK ( ManyTable[ManyColumn], 0 )

Since FIRSTNONBLANK carries out a context transition (behind the scenes), it ends up creating a filter context equivalent to the current row, which filters the table on the many-side. Read more here: https://dax.guide/firstnonblank/

 

The RELATEDTABLE function is also available to return the entire table on the many-side corresponding to the current row. You could use RELATETABLE then manipulate that in some way to produce a scalar result.

 

Regards,

Owen

 



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
OwenAuger Super Contributor
Super Contributor

Re: RELATED function - how it works

@reddy_powerbi 

That's right, RELATED (which can only be used in a row context) follows a chain of one or more many-to-one relationships to retrieve a column value on the one-side.

 

Since RELATED returns a scalar value, isn't able to retrieve a value on the many-side, since there could be multiple values of a given column on the many-side.

 

One way you could lookup a single value on the many-side is using a function like FIRSTNONBLANK to return the "minimum" value.

Something like

Min Value on many side =
FIRSTNONBLANK ( ManyTable[ManyColumn], 0 )

Since FIRSTNONBLANK carries out a context transition (behind the scenes), it ends up creating a filter context equivalent to the current row, which filters the table on the many-side. Read more here: https://dax.guide/firstnonblank/

 

The RELATEDTABLE function is also available to return the entire table on the many-side corresponding to the current row. You could use RELATETABLE then manipulate that in some way to produce a scalar result.

 

Regards,

Owen

 



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 142 members 1,789 guests
Please welcome our newest community members: