Learn Excel - Combine Workbooks With Common Column - Podcast 2216

If you like this content, please consider visiting the video on YouTube and subscribe to the MrExcel Channel to show your support!
This video has been published on Jun 14, 2018.
David from Florida has two workbooks that he wants to combine.
Both workbooks have the same field in column A, but then different data in the remaining columns.
One workbook might have extra items that are not in the other and David wants to see those.
There are no duplicates in either file
You can use Power Query to solve this.
In David's case, each data set is in a separate workbook.
Start in a new blank workbook on a blank worksheet.
Step 1: Data, From File, Workbook. Close & Load to… Only Create Connection
Step 2: Data, from File, Workbook. Close & Load to… Only Create Connection
Step 3: Data, Get Data, Merge. Select the two connections. Select the column common in both.
For the join type: All from larger file, matching from smaller
If the original data changes, you can refresh the query.
To download this workbook: https://www.mrexcel.com/download-center/2018/06/combine-based-on-common-column.xlsx
maxresdefault.jpg


Transcript of the video:
Learn Excel from MrExcel Podcast, Episode 2216.
Combine Two Workbooks Based on a Common Column.
Hey, welcome back to MrExcel netcast, I'm Bill Jelen. Today's question's from David, who was in my seminar in Melbourne, Florida, for the Space Coast Chapter of the IIA.
David has two different workbooks where Column A is in common between both of them.
So, here's Workbook 1, here's Workbook 2-- both have product code.
This one has items that the first one doesn't have, or vice versa, and David wants to combine all the columns.
So, we have three columns here and four columns here.
I put both of these in the same workbook, in case you're downloading the workbook to work along.
Take each one of these, move it out to its own workbook and save it.
Alright, to combine these files, we're going to use Power Query.
Power Query's built into Excel 2016.
If you're in the Windows version of 10 or 13, you can go out to Microsoft and download Power Query.
You can start from a new blank workbook with a blank worksheet.
You're going to save this file-- Save as, you know, maybe Workbook, to show the results of combined files .xlsx.
Alright?
And what we're going to do is, we're going to do two queries.
We're going to go to Data, Get Data, From File, From Workbook, and then we'll choose the first file.
In a preview, select the sheet that has your data, and we don't have to do anything to this data.
So just open the load box and choose Load To, Only Create Connection, click OK.
Perfect.
Now, we're going to repeat that for the second item-- Data, From File, From a Workbook, choose DavidTwo, choose the sheet name, and then open the load, Load To, Only Create a Connection.
You'll see over here in this panel, we have both connections present.
Alright.
Now the actual work-- Data, Get Data, Combine Queries, Merge, and then in the Merge dialog, choose DavidOne, DavidTwo, and this next step is completely unintuitive.
You have to do this.
Choose the column or columns in common-- so Product and Product.
Alright.
And then, be very careful here with the join type.
I want all rows from both because one might have an extra row and I need to see that, and then we click OK.
Alright.
And here's the initial result.
It doesn't look like it worked; it doesn't look like it added the extra items that were in file 2.
And we have this column 5-- it's null now.
I'm going to right click column 5 and say, Remove that column.
So open this expand icon and uncheck this box for Use original column name as prefix, and BAM! it works.
So the extra items that were in File 2, that aren't in File 1, do appear.
Alright.
Now in today's file, it looks like this Product Code column is better than this Product column, because it has extra rows.
But there might be a day in the future where Workbook 1 has things that Workbook 2 doesn't have.
So I'm going to leave both of them there, and I'm not going to get rid of any nulls because, like, even though this row at the bottom appears to be completely null, there might be in the future a situation where we have a few nulls in here because something's missing.
Alright?
So, finally, Close & Load, and we have our sixteen rows.
Now, in the future, let's say that something changes.
Alright, so we'll go back to one of those two files and I'll change the class for Apple to 99, and let's even insert something new and save this workbook.
Alright.
And then, if we want our merge file to update, come over here-- now, watch out, when you do this the first time, you can't see the Refresh icon-- you have to grab this bar and drag it over.
And we will do Refresh, and 17 rows loaded, the watermelon appears, the Apple changes to 99-- it's a beautiful thing.
Now, hey, do you wanna learn about Power Query?
Buy this book by Ken Puls and Miguel Escobar, M is for (DATA) MONKEY.
I'll get you up to speed.
Wrap-up today: David from Florida has two workbooks that he wants to combine.
They both have the same fields in Column A, but the other columns are all different.
One workbook might have extra items that are not in the other and David wants those.
There's no duplicates in either file. We're going to use power query to solve this.
So start in a new blank workbook on a blank worksheet.
You're going to do three queries, first one-- Data, From File, Workbook, and then Load to only Created Connection.
The same thing for the second workbook, and then Data, Get Data, Merge, select the two connections, select the column that's common in both--in my case, Product-- and then from the Join Type, you want to full join all from the File 1, all from File 2.
And then the beautiful thing is if the underlying data changes, you can just refresh the query.
To download the workbook from today's video, visit the URL in the YouTube description.
Well, hey, I want like David for showing up for my seminar, I want to thank you for stopping by.
I'll see you next time for another netcast from MrExcel.
 

Forum statistics

Threads
1,221,567
Messages
6,160,531
Members
451,655
Latest member
rugubara

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top