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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JemmaD
Resolver II
Resolver II

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! 

1 ACCEPTED SOLUTION

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"})}))



View solution in original post

4 REPLIES 4
JemmaD
Resolver II
Resolver II

I got this:

= Table.Combine({Table.FromColumns({Policies[Product]}, {"Product"}), Table.FromColumns ({Quotes[Product]}, {"Product"})})
But it doesn't create a distinct list

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"})}))



ITManuel
Responsive Resident
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"

Apparently there is a way to select the Product column within the Table.Combine argument, I just can't get the syntax right. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.