Skip to main content

How to merge two or more tables into one based on key columns?

Supposing you have three tables in a workbook, now, you want to merge these tables into one table based on the corresponding key columns to get the result as below screenshot shown. This may be a troublesome task for most of us, but, please don’t worry, this article, I will introduce some methods for solving this problem.

    

Merge two or more tables into one based on key columns with Power Query function (Excel 2016 and later versions)

Merge two or more tables into one based on key columns with an amazing feature


Merge two or more tables into one based on key columns with Power Query function (Excel 2016 and later versions)

To use the Power Query function for joining multiple tables into one based on the corresponding key columns, please do with the following step by step:

1. If your data ranges are not table format, first, you should convert them to tables, please select the range, and then click Insert > Table, in the Create Table dialog box, click OK button, see screenshots:

2. After creating tables for each of the data ranges, then, select the first table, and then click Data > From Table / Range, see screenshot:

3. Then, in the Table1-Power Query Editor window, click Home > Close & Load > Close & Load To, see screenshot:

4. In the popped out Import Data, select Only Create Connection option, and then click OK button, see screenshot:

5. Then the first connection table is created in the Queries & Connections pane, now, repeat the above step 2-step 4 for creating the connection tables for the other two tables that you want to merge. When finished, you will get the below screenshot shown:

6. After creating the connections for the tables, then, you should merge first two tables into one, please click Data > Get Data > Combine Queries > Merge, see screenshot:

7. In the Merge dialog box, please do the following operations:

  • (1.) Select the first table from the first drop down list;
  • (2.) Select the second table that you want to merge from the second drop down list;
  • (3.) In the preview pane, click on the matching column from the two tables separately to select them, and the selected columns will become green.
  • (4.) In the Join Kind drop down, select Left Outer (all from first, matching from second) option.

8. Then, click OK button, in the Merge1-Power Query Editor window, click  button, see screenshot:

9. And then, in the expanded box:

  • (1.) Keep the default Expand option selected;
  • (2.) In the Select All Columns list box, check the column name that you want to merge to the first table;
  • (3.) Uncheck the Use original column name as prefix option.

10. Then, click OK button, now, you can see the column data in the second table has been added into the first table, see screenshot:

11. In this step, the first table and the second table has been merged by the key column successfully, now, you need to import this merged table to a new merge connection table, please click Home > Close & Load > Close & Load To, see screenshot:

12. In the popped out Import Data dialog box, select Only Create Connection option, and click OK button, see screenshot:

13. Here, you can see a connection is created which named Merge1 in the Queries & Connections pane, see screenshot:

14. After merging the first two tables, now, you need to combine the new Merge1 table with the third table, please click Data > Get Data > Combine Queries > Merge, and in the Merge dialog box, do the following operations:

  • (1.) Select the Merge1 table from the first drop down list;
  • (2.) Select the third table that you want to merge from the second drop down list;
  • (3.) In the preview pane, click on the matching column from the two tables separately to select them, and the selected columns will become green;
  • (4.) In the Join Kind drop down, select Left Outer (all from first, matching from second) option.

15. And then, click OK, in the Merge2-Power Query Editor window, click button, and in the expanded box, check the column name that you want to combine from the third table, and uncheck the Use original column name as prefix option as well, see screenshot:

16. Then, click OK button, you will get a merged table with the three tables together, and now, you should import this merged table to a new table sheet, please click Home > Close & Load > Close & Load To, see screenshot:

17. In the Import Data dialog box, select Table and New worksheet options, see screenshot:

18. At last, a new table with the data from the three tables based on the corresponding key columns has been created in a new worksheet as below screenshot shown:

Tips:

1. If your original data changes, you need the merged table is changed as well, please click one cell in your merged table, and then click Query > Refresh to get the refreshed data. See screenshot:

2. With this function, you can also merge much more tables by repeating the above steps.


Merge two or more tables into one based on key columns with an amazing feature

This section, I will show a useful feature – Table Merge of Kutools for Excel, with this feature, you can quickly merge two or more tables into one table based on key columns.

For example, I have two tables wanted to be merged as below screenshot shown:

Tips:To apply this Table Merge feature, firstly, you should download the Kutools for Excel, and then apply the feature quickly and easily.

After installing Kutools for Excel, please do as this:

1. Click Kutools Plus > Table Merge, see screenshot:

2. In the first step of the Tables Merge wizard, please select the main table and lookup table separately, (Note: the column data in lookup table will be added to the main table), see screenshot:

3. In the step 2 of the Tables Merge wizard, please check the key column name that you want to merge the tables based on, see screenshot:

4. Click Next button, in the step 3 of the Table Merge wizard, please click Next button directly, see screenshot:

5. And then, in the step 4 of the wizard, check the column name from the lookup table that you want to add in the main table, see screenshot:

6. Go on clicking Next button, in the last step of the wizard, in the Add options list box, check Add mismatched rows to the end of the main table option, at the same time, you can also select the operations for the duplicated rows as you need. See screenshot:

7. Then, click Finish button, the corresponding data column in lookup table will be added into the main table as below screenshot shown:

Tips:

1. With this feature, you can update the data in a main table by another table as you need.

2. To merge more tables, you just need to select the result of the new merged data as the main table, and then repeat the above steps.

Click to Download Kutools for Excel and free trial Now!


More relative articles:

  • Merge And Combine Rows Without Losing Data In Excel
  • Excel only keeps the data in the upper-left most cell, if you apply "Merge & Center" command (Home tab > Merge & Center on the Alignment panel) to merge rows of data in Excel. Users have to use another method to merge multiple rows of data into one row without deleting data. This tutorial is going to present you the method of how to merge rows of data into one row.
  • Merge Two Tables By Matching A Column In Excel
  • Supposing you have two tables in two different sheets, one is main table, and the other is new data table. Now you want to merge these two tables by a matching column and update the data as below screenshot shown, how can you quickly solve it in Excel? In this article, I will introduce the tricks on combining two tables by a column quickly.
  • Combine Duplicate Rows And Sum The Values In Excel
  • In Excel,you may always meet this problem, when you have a range of data which contains some duplicate entries, and now you want to combine the duplicate data and sum the corresponding values in another column, as following screenshots shown. How could you solve this problem?
  • Combine Multiple Workbooks Into One Master Workbook In Excel
  • Have you ever been stuck when you have to combine multiple workbooks into a master workbook in Excel? The most terrible thing is that the workbooks you need to combine contain multiple worksheets. And how to combine only the specified worksheets of multiple workbooks into one workbook? This tutorial demonstrates several useful methods to help you solve the problem steps by steps.

  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations