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
GooseHelpful199
Frequent Visitor

Can I combine columns from multiple queries? (Stack, not concatenate)

I have two different columns with a list of codes (with overlap and duplicates) I want to combine into one large list with all the results. If I have Column1 and Column2 existing in 2 separate queries, how would I go about creating a new query that combines these two columns into one, while removing duplicates?

Looking for a solution that would work assuming that the real values of Column1 and Column2 are actually Custom Columns made in Power Query, since they are really concatenated keys.

GooseHelpful199_3-1665693938503.png

 

 

 

2 ACCEPTED SOLUTIONS
serpiva64
Super User
Super User

Hi,

in power query you append the two queries as New

serpiva64_0-1665696284286.png

then merge your columns

serpiva64_1-1665696377825.png

and finally remove duplicates

serpiva64_2-1665696418518.png

and you obtain your result

serpiva64_3-1665696471589.png

In dax you can create a calculated table

Table = DISTINCT(UNION(Query1,Query2))
 and obtain 
serpiva64_4-1665696659396.png

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

 

 

 

 

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Ensure that the headings in both tables are the same.  In the Query Editor, append the two tables and then Remove Duplicates.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Ensure that the headings in both tables are the same.  In the Query Editor, append the two tables and then Remove Duplicates.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
serpiva64
Super User
Super User

Hi,

in power query you append the two queries as New

serpiva64_0-1665696284286.png

then merge your columns

serpiva64_1-1665696377825.png

and finally remove duplicates

serpiva64_2-1665696418518.png

and you obtain your result

serpiva64_3-1665696471589.png

In dax you can create a calculated table

Table = DISTINCT(UNION(Query1,Query2))
 and obtain 
serpiva64_4-1665696659396.png

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

 

 

 

 

Thank you for the detailed screenshots, this worked perfectly!

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.