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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
WillianLopes
New Member

Merge rows from different tables using Power Query

I have 2 separate tables to store products. Although it is 2 different tables, their structure is exactly the same.

 

In these tables, each line has an item and the indication to which departments it should be made available.

 

However, because there are 2 tables, the same item can appear in the tables and in each one marking different departments.

 

I would like to make a table unifying the 2 previous ones and making sure that the item that appears repeated in the tables does not come out in 2 lines but that its line is merged, pointing in the new table the departments of the 2 tables.

 

Obviously this concept of departments is not real, I just used it to try to better explain my situation.

 

Please can you help me to resolve this?

 

APAGAR.png

1 ACCEPTED SOLUTION
jennratten
Super User
Super User

Hello - here is how you can accomplish this.

SCRIPT

let
    Source = Table.Combine({Table01, Table02}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"Product"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Value] = "x")),
    #"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

jennratten_0-1679318928329.png

 

View solution in original post

2 REPLIES 2
WillianLopes
New Member

That's perfect!

jennratten
Super User
Super User

Hello - here is how you can accomplish this.

SCRIPT

let
    Source = Table.Combine({Table01, Table02}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"Product"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([Value] = "x")),
    #"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

jennratten_0-1679318928329.png

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.