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
Anonymous
Not applicable

How to merge two tables by a column using M power query?

Hi,

 

I've currently got two tables that I'm trying to merge, one is from a data source and the other is a custom table that's been created in Power BI. I've updated the custom table with a new row data  and works fine. Now, I would like to include this new row into my source table by combining the two.

 

I was able to initially merge this using related tables, but after adding in a new row, the related table doesn't seem to pull the updated data from the custom table. From reading articles, it was recommended to do power query instead of dax? I've applied a merge query but this also doesn't seem to work as I still couldn't see the new row/definition from custom table? Any suggestions would be really appreciated... I'm novice in M an I can't seem to work out what it is Im doing wrong?

 

 

Custom Table  
Existing RowData AData
New RowData BData

 

Wanted outcome:

Source Data Table  
Existing RowData AData
New RowData BData
1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

When you merge in Power Query you get to choose the Join Kind (how the tables are merged).  The merge requires a matching column in both tables with values that can be linked together.

The default join in PQ is Left Outer which means it will omit rows in the 2nd table if there isn't a matching value in the 1st table.

In this image, the tables are being joined on the Name column.

join-kind.png

If your new row in the 2nd table doesn't have a corresponding value in Table 1 - like the name DD in the above image, it won't get merged into the new table if you use a Left Outer Join.

left-outer.png

If you are still having trouble with this, please post your tables so I can see what data you are working with.

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
PhilipTreacy
Super User
Super User

@Anonymous 

No worries 🙂



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @Anonymous 

When you merge in Power Query you get to choose the Join Kind (how the tables are merged).  The merge requires a matching column in both tables with values that can be linked together.

The default join in PQ is Left Outer which means it will omit rows in the 2nd table if there isn't a matching value in the 1st table.

In this image, the tables are being joined on the Name column.

join-kind.png

If your new row in the 2nd table doesn't have a corresponding value in Table 1 - like the name DD in the above image, it won't get merged into the new table if you use a Left Outer Join.

left-outer.png

If you are still having trouble with this, please post your tables so I can see what data you are working with.

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Hi @PhilipTreacy 

 

Well, I'm just feeling really silly now. I did previously merge using the left outer join but didn't think to double check the formatting of the name. The notorious extra spacing caught me. I've removed this and I'm now able to merge the two tables.

 

Thank you for your help 🙂

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.

Top Solution Authors
Top Kudoed Authors