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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
DennisGaida
Frequent Visitor

Merge multiple queries depending on ID match

I'm thinking I have to do some kind of UNION, but I can't figure it out. The blog post Combine multiple tables with UNION / UNION ALL in ... - Microsoft Power BI Community helped, but I didn't get very far.

 

I have three tables:

Connections

connectionid1_valueentityid
6c3bd0e4-f248-41e8-b27c-bb46096bc061f942f7c1-4c5a-44cd-a11a-3900904ce733
1e40df90-7017-4322-a70b-7a10a096c29cf942f7c1-4c5a-44cd-a11a-3900904ce733

Users1

useridfirstnamelastnameemail
6c3bd0e4-f248-41e8-b27c-bb46096bc061JohnWickjohnwick@example.org
ce9fe849-c94d-4c6e-822c-b11bba50f116PetraParkerpetraparker@example.org
f61f4b5d-f4ec-4c12-bb0f-61a0bba26ddaMaxieMoxiemaxiemoxie@example.org

Users2

uidu_firstu_lastu_mail
1e40df90-7017-4322-a70b-7a10a096c29cJohnWickjohnwick@example.org
f6e12d0e-43c6-4fd0-8dad-27eefdc48318MaxieMoxiemaxiemoxie@example.org

 

Basically I want to join the connections to the users - each ID in connectionid1_value corresponds to another ID in either the Users1 or Users2 table. And the either part is what is throwing me off.

 

I can merge the Users1 and Users2 table in the Power Query editor (leveraging the e-mail as primary key) into MergedUsers, but I can't seem to figure out the missing link, because when I would try to do two joins (connections.connectionid1_value > MergedUsers.userid & connections > MergedUsers.uid) I can only do a many:many relationship which doesn't seem right.

 

How do I map the GUID in connectionid1_value to either column userid or column uid depending on where it is matched (this is when using the MergedUsers table)?

 

For completeness sake the MergedUsers table (note that not all users have a uid / are in the Users2 table):

useridfirstnamelastnameemailuid
6c3bd0e4-f248-41e8-b27c-bb46096bc061JohnWickjohnwick@example.org1e40df90-7017-4322-a70b-7a10a096c29c
ce9fe849-c94d-4c6e-822c-b11bba50f116PetraParkerpetraparker@example.org 
f61f4b5d-f4ec-4c12-bb0f-61a0bba26ddaMaxieMoxiemaxiemoxie@example.orgf6e12d0e-43c6-4fd0-8dad-27eefdc48318
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@DennisGaida you can append both tables together in PQ, before you append, make sure column names are the same and this will create Union of both the tables and then you will only set relationship with UserId.

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
DennisGaida
Frequent Visitor

This got me on the right track, thank you!

 

I created an append query, but also a merge query. The append query I can use to filter based on a single userid, the merged query I can use to get all the information on the particular user from all user tables.

parry2k
Super User
Super User

@DennisGaida you can append both tables together in PQ, before you append, make sure column names are the same and this will create Union of both the tables and then you will only set relationship with UserId.

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.