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
pedroccamara
Helper II
Helper II

Relate same table twice

Hello

I have a problem and still don't know how to solve it.

The main db has two fields with the same data. It is a username of the person whatever. And i have another db that has all usernames and their names. I just want to show their names in both cases. It means, i think, i had to creat a relation from de 2nd db to the first db, twice. I'm not sure if this is possible. Is it?

Tks

Pedro

1 ACCEPTED SOLUTION

@pedroccamara

 

We cannot make two relationships active at the same time for two tables here. Using an inactive relationship is a way. This article should be a good reference.

Actually, we don’t need two relationships in some situations. As @dejanle posted above, if we have two tables as below. We can create a relationship between Sell-to_Customer_No and Customer_No to get Sell-to Custome_Name.

Relate same table twice_1.jpgRelate same table twice_2.jpg

 

We can also get Bill-to_Customer_Name by creating a column using LOOKUPVALUE without relationship.

Bill Customer Name = 
LOOKUPVALUE ( DB2[Customer_Name], DB2[Customer_No], DB1[Bill-to_Customer_No] )

Relate same table twice_3.jpg

 

Best Regards,

Herbert

View solution in original post

11 REPLIES 11
v-haibl-msft
Employee
Employee

@pedroccamara

 

Not sure how do you want to show their names. But I think you can create an active and an inactive relationship between two tables.

Please refer to this document.

Relate same table twice_1.jpg

 

Best Regards,

Herbert

Hello Herbert and many thanks for your reply

The problem with your solution is that i don't want to determine wich relation has priority above the other.

Tey are both important to me.

But i think i have to work it in other way. Don't know how since the table is design like this. Maybe duplicating a table....but that can be "dangerous".

Anyway. Tks a lot.

Brest regards

Pedro

@pedroccamara You providing a sample of what your issue is will go a long way in helping us determine a solution. Just throw down some sample data...

Does your scenerio look something like this?

 

DB1                           DB2

Username                  Username     Name

suser                          suser             sample user

tuser                          tuser              test user


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

yes. that's it

I have a similar problem and am looking forward to the answer. The example is as follows. We have a database of sales invoices in which you have two different customers: Sell-to Customer No. and Bill-to Customer No. (the first one is the customer who ordered goods, the second one will pay the invoice). Both Sell-to Customer No. and Bill-to Customer No. relate to the Customer List. So I would like to get Customer Name for both Sell-to Customer No. and Bill-to Customer No. In terms od databases, the situation is:

DB1:

Invoice_No

Sell-to_Customer_No

Bill-to_Customer_No

 

DB2:

Customer_No

Customer_Name

 

I want to be able to link DB1 to DB2 twice, to get both Sell-to Custome_Name and Bill-to_Customer_Name. Power BI, does not allow me to do both, either one or the other.

Vvelarde
Community Champion
Community Champion

You can create 1 active and many inactive relationship.

 

After when i need to use a inactive relationship just put in dax USERELATIONSHIP(Table1[Colum], Table2[Column])

 

Hope this can help you




Lima - Peru

Hi Vvelarde

Thanks for your answer.

The problem is that i don't know where and how to use it. Everyday your database is growing and it's simple for me to refresh it and it's updated. I've miss the dax lesson also.

Best regards

Pedro

@pedroccamara

 

We cannot make two relationships active at the same time for two tables here. Using an inactive relationship is a way. This article should be a good reference.

Actually, we don’t need two relationships in some situations. As @dejanle posted above, if we have two tables as below. We can create a relationship between Sell-to_Customer_No and Customer_No to get Sell-to Custome_Name.

Relate same table twice_1.jpgRelate same table twice_2.jpg

 

We can also get Bill-to_Customer_Name by creating a column using LOOKUPVALUE without relationship.

Bill Customer Name = 
LOOKUPVALUE ( DB2[Customer_Name], DB2[Customer_No], DB1[Bill-to_Customer_No] )

Relate same table twice_3.jpg

 

Best Regards,

Herbert

Many thanks for your answer.

Gonna try with vlookup

 

Best regards

Pedro

@pedroccamara Can you provide an example? Are you going to import the data or use a different connection type like direct query to these sources? If you import the data into Power BI Desktop, there are a bunch of ways you can merge, clean up your data set to display how you want it.


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

Hello Eno and many thanks for your help.

The problem is that i have 2 identical fields from a table. Both are showing usernames and i have a table to relate to both. Power bi "said" i can't do it. Either one field or the other. Not both. My question, cose i'm running out of ideas, how to do it in other way?

Many thanks

Best regards

Pedro

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.