Forum Discussion
Union two columns from two tables together in Power Query
Hi there,
I have two tables : Policies and Quotes. In both tables is a column called [Product]
I want to create a dimension table holding distinct values of [Product] from both Policies and Quotes tables.
I want to do this in m query, not Dax.
Please help with the syntax!
Solved! Just stick a Table.Distinct in front of the Table.Combine query and add an additional close parameter at the end of the query:
= Table.Distinct(Table.Combine({Table.FromColumns({Policies[Product]}, {"Product"}), Table.FromColumns ({Quotes[Product]}, {"Product"})}))
4 Replies
- ITManuel
Responsive Resident
Hi JemmaD ,
you can do this pretty easily via the graphical interface in Power Query.
1. Append the two tables as new tables
2. Remove all columns except [Product]
3. Remove duplicates from the column [Product]
This would be the M code
let Source = Table.Combine({Policies, Quotes}), #"Removed Other Columns" = Table.SelectColumns(Source,{"Product"}), #"Removed Duplicates" = Table.Distinct(#"Removed Other Columns") in #"Removed Duplicates"- JemmaD
Helper V
Apparently there is a way to select the Product column within the Table.Combine argument, I just can't get the syntax right.
- JemmaD
Helper V
I got this:
= Table.Combine({Table.FromColumns({Policies[Product]}, {"Product"}), Table.FromColumns ({Quotes[Product]}, {"Product"})})
But it doesn't create a distinct list- JemmaD
Helper V
Solved! Just stick a Table.Distinct in front of the Table.Combine query and add an additional close parameter at the end of the query:
= Table.Distinct(Table.Combine({Table.FromColumns({Policies[Product]}, {"Product"}), Table.FromColumns ({Quotes[Product]}, {"Product"})}))