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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

using inactive relationship

Hello all,

I have a question about how to configure certain relations.

I have data like the following:

"T1" Lookup table for id code

idcode
1a
2b
3c
4d
5f

"T2" table with id's (irl it has more columns but they are irrelevant for this question)

id_1id_2
13
32
43
11
55

I configured a relation with T1_id and T2_id_1 and another relation between T1_id and T2_id_2

Now what I want to achieve is the following:

id_1codeid_2code
1a3c
3c2b
4d3c
1a2b
5f3c


I tried to do this with the "Related" command but since  you can only have on active relation between two tables this only works for either the code of id_1 or the code of id_2.

I could solve this by duplicating the lookuptable and making using one lookuptable per id_1 of id_2 but that doesnt feel really "clean". I was wondering if there is a way to solve this in a better way for example something like the "userelationship" command. Since I would like to choose the relation that the "related" command uses.

I hope someone has an idea to push me into the right direction.

 

Best regards,

L.Meijdam

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

assuming you want to create a calculated column, you can do this by using this DAX statement, just utilize the DAX function LOOKUPVALUE (it's totally independent from relationships):

code id 2 = 
LOOKUPVALUE('T1'[code],'T1'[id],'T2'[id_2]) 

Due to the fact that the usage of USERELATIONSHIP needs a CALCULATE that leads to context transition, and so on and so on. I would not recommend to use USERELATIONSHIP but instead plain vanilla LOOKUPVALUE. The DAX would become much more complex and depending on performance impacts can be neglected, due the fact that this calculation happens just during data refresh and not during query execution.

Regards,
Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey,

 

assuming you want to create a calculated column, you can do this by using this DAX statement, just utilize the DAX function LOOKUPVALUE (it's totally independent from relationships):

code id 2 = 
LOOKUPVALUE('T1'[code],'T1'[id],'T2'[id_2]) 

Due to the fact that the usage of USERELATIONSHIP needs a CALCULATE that leads to context transition, and so on and so on. I would not recommend to use USERELATIONSHIP but instead plain vanilla LOOKUPVALUE. The DAX would become much more complex and depending on performance impacts can be neglected, due the fact that this calculation happens just during data refresh and not during query execution.

Regards,
Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Hi @TomMartens,

 

Thanks for  your reply this solution gives the result I was hoping to achieve, and it is alot cleaner then what I had thought of.


Best regards,
L.Meijdam 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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