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
kgiboin
Helper I
Helper I

Merge table by Column Join?

Hi here is my problem-

I have two query output tables (sample data below):

 

kgiboin_0-1642426034900.png

 

I want to add columns to table 1 with the contract information from table 2, but only where the suppliers match, I.E SUP2 in Table 1 might not be equal to SUP2 in Table 2, or even be in that dataset for that matter.

 

Alternatively, If I can recreate Table 2 with only the suppliers that exist in Table 1 I can just load that new table next to Table 1. That also works.

 

I think I might be able to figure it out if I was to transpose the tables and do a join based on supplier names, but is there a better way to do that? not even sure thats doable yet.

Any Ideas?

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @kgiboin ,

 

1) Select the [Part Number] column in your first table (t1), then go to Transfom tab > Unpivot Columns (dropdown) > Unpivot Other Columns.

2) Do the same on your second table (t2).

2.5) At this point, you can edit the generated code (or just add a rename step) to rename your columns to something more useable than 'Attribute' and 'Value'. I will assume 'Attribute' has been changed to 'Supplier'.

3) Select the t1 query, then go to Home tab > Merge Queries.

4) In the merge dialog, multi-select (Ctrl+click) [Part Number], then [Supplier], in that order on t1 (top preview box).

5) Do the same (on the same columns, in the same order) for t2 (bottom preview box).

6) Hit ok and expand your resulting merged column.

 

This will firstly allow you to do a merge on two table dimensions at the same time and, secondly, will have structured your data in the most efficient format for reporting.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @kgiboin ,

 

1) Select the [Part Number] column in your first table (t1), then go to Transfom tab > Unpivot Columns (dropdown) > Unpivot Other Columns.

2) Do the same on your second table (t2).

2.5) At this point, you can edit the generated code (or just add a rename step) to rename your columns to something more useable than 'Attribute' and 'Value'. I will assume 'Attribute' has been changed to 'Supplier'.

3) Select the t1 query, then go to Home tab > Merge Queries.

4) In the merge dialog, multi-select (Ctrl+click) [Part Number], then [Supplier], in that order on t1 (top preview box).

5) Do the same (on the same columns, in the same order) for t2 (bottom preview box).

6) Hit ok and expand your resulting merged column.

 

This will firstly allow you to do a merge on two table dimensions at the same time and, secondly, will have structured your data in the most efficient format for reporting.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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.