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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Hircon
New Member

Relate tables based on more than one column

Hi,

 

I have two tables I'd like to relate to each other based on product number. The difficulty is that many products have two different product numbers, divided into two seperate columns in the second table. The relevant columns look something like this:

 

Table1: includes ticket information

Ticket_IDProduct
15001
28463
3484436
4800006
59401

 

Table2: includes product information, including current product number and old product number where it exists

ProductOld ProductDescription
5001800006Apple
8463486624Banana
5648484436Orange
9401nullMango
4810110011Lemon

 

I'd like to either combine these tables in power query or relate them in the model so I can display the product properties along with the Ticket data regardless of whether the ticket comes in with the new product number or the old one. How would I best do this?

 

Desired result:

Ticket_IDProductDescription
15001Apple
28463Banana
3484436Orange
4800006Apple
59401Mango

 

1 ACCEPTED SOLUTION
Shravan133
Super User
Super User

  1. Load Tables into Power Query:

    • Load both Table1 and Table2 into Power Query.
  2. Duplicate and Unpivot Table2:

    • In Table2, duplicate it and then unpivot it to have all product numbers (new and old) in a single column:
    • Go to the Transform tab, select the Product and Old Product columns, then choose Unpivot Other Columns.
    • This will create a new column, called Attribute, with values "Product" and "Old Product," and another column called Value with the product numbers.
    • Rename the Value column to Product Number.
  3. Remove Nulls in Product Number:

    • Filter out any rows in the new Product Number column where the value is null.
  4. Merge Tables:

    • Now, go to Table1 and select Merge Queries.
    • Choose Table1 as the primary table and the transformed Table2 as the table to merge with.
    • In the merge dialog, select Product from Table1 and Product Number from the transformed Table2.
    • Use a Left Outer Join to ensure all ticket information is retained, and click OK.
  5. Expand Merged Table:

    • After merging, expand the columns from Table2 in Table1 to bring in the Description.
    • You’ll see columns for the product Description for both new and old product numbers.
  6. Finalize:

    • Remove any unnecessary columns, rename as needed, and load the table back to the model.

Result

The resulting table should look like this:

Ticket_ID Product Description

15001Apple
28463Banana
3484436Orange
4800006Apple
59401Mango

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

hi @Hircon 

 

In Power Query, on table2, 
  1. select Description column and
  2. unpivot other columns,
  3. add an index column, 
you shall get the desired result table
Shravan133
Super User
Super User

  1. Load Tables into Power Query:

    • Load both Table1 and Table2 into Power Query.
  2. Duplicate and Unpivot Table2:

    • In Table2, duplicate it and then unpivot it to have all product numbers (new and old) in a single column:
    • Go to the Transform tab, select the Product and Old Product columns, then choose Unpivot Other Columns.
    • This will create a new column, called Attribute, with values "Product" and "Old Product," and another column called Value with the product numbers.
    • Rename the Value column to Product Number.
  3. Remove Nulls in Product Number:

    • Filter out any rows in the new Product Number column where the value is null.
  4. Merge Tables:

    • Now, go to Table1 and select Merge Queries.
    • Choose Table1 as the primary table and the transformed Table2 as the table to merge with.
    • In the merge dialog, select Product from Table1 and Product Number from the transformed Table2.
    • Use a Left Outer Join to ensure all ticket information is retained, and click OK.
  5. Expand Merged Table:

    • After merging, expand the columns from Table2 in Table1 to bring in the Description.
    • You’ll see columns for the product Description for both new and old product numbers.
  6. Finalize:

    • Remove any unnecessary columns, rename as needed, and load the table back to the model.

Result

The resulting table should look like this:

Ticket_ID Product Description

15001Apple
28463Banana
3484436Orange
4800006Apple
59401Mango

The unpivot was exactly the step I was missing. Thank you!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors