Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Merging Excel Tables: The Best Ways to Combine Data

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Merging Excel tables is best achieved using Power Query (Get & Transform), which allows you to join two or more datasets based on a common column (a unique identifier) without manually copying and pasting data. This process creates a dynamic link between your source tables and the merged result, meaning any updates to the original data can be reflected in the merged table with a single click of the Refresh button. To do this, you need your data formatted as official Excel Tables (Ctrl+T) and a shared column—such as an Employee ID or Order Number—that exists in both sets of data.

What You'll Need

  • Microsoft Excel (Power Query is built-in for versions 2016 and later; for 2010 or 2013, it is a separate add-in).
  • Two or more datasets formatted as Tables (Select your data and press Ctrl+T).
  • A "Key Column": A column with unique values that appears in both tables to act as the anchor for the merge.
  • Consistent data types: Ensure the key columns in both tables are set to the same format (e.g., both as Text or both as Number).

Step-by-Step

  1. Convert Data to Tables: Select the first range of data you want to merge. Press Ctrl+T and ensure "My table has headers" is checked. Click OK. Repeat this for the second dataset. Note that labels and menu paths may differ slightly depending on your version of Excel or region.
  2. Name Your Tables: With the first table selected, go to the Table Design tab in the top ribbon. In the Table Name box on the far left, give it a descriptive name (e.g., "SalesData"). Repeat this for the second table (e.g., "CustomerInfo"). This makes the merging process much easier to track.
  3. Load First Table to Power Query: Click anywhere inside the first table. Go to the Data tab on the ribbon and select From Table/Range. This will open the Power Query Editor window.
  4. Close and Load as Connection: In the Power Query Editor, you don't need to make changes yet. Click the arrow under Close & Load in the Home tab and select Close & Load To.... In the dialog box that appears, select Only Create Connection and click OK. This tells Excel to remember the data without duplicating it on a new sheet.
  5. Load Second Table to Power Query: Repeat the process for the second table: select the table, go to Data > From Table/Range, then Close & Load To... > Only Create Connection.
  6. Initiate the Merge: Go to the Data tab, click Get Data, then select Combine Queries > Merge.
  7. Select the Tables and Key Columns: A Merge dialog box will appear. In the first dropdown menu, select your first table (e.g., "SalesData"). In the second dropdown, select your second table (e.g., "CustomerInfo"). Now, click on the matching column in both preview windows (e.g., click "CustomerID" in the top preview and "CustomerID" in the bottom preview). The columns will be highlighted.
  8. Choose the Join Kind: Below the previews, you will see a Join Kind dropdown. For most users, Left Outer is the correct choice; this keeps all rows from the first table and adds matching data from the second. If you only want rows that exist in both tables, choose Inner. Click OK.
  9. Expand the Merged Column: You will now be back in the Power Query Editor. You will see a new column at the end of your first table containing the word "Table" in every cell. Click the Expand icon (two diverging arrows) in the top-right corner of that column header.
  10. Select Specific Columns: Uncheck "Use original column name as prefix" to keep your headers clean. Select only the specific columns you want to bring over from the second table. Click OK.
  11. Load the Final Result: Now that the data is merged, click Close & Load. Excel will create a new worksheet containing your combined, merged table.

Common Mistakes

One of the most frequent errors is attempting to merge tables that have different data types in their key columns. For example, if the "ID" column in Table A is formatted as a Number, but the "ID" column in Table B is formatted as Text, Power Query will not find any matches, and your merged columns will be filled with null values. Always check the data type icon (e.g., 1.2 or ABC) next to the column header in the Power Query Editor.

Another common mistake is forgetting to name the tables. If you leave them as "Table1" and "Table2," it becomes very easy to select the wrong dataset during the merge process, especially when working with large workbooks. This often leads to "circular reference" errors or incorrectly mapped data.

Users also frequently choose the wrong Join Kind. Selecting "Inner Join" when you actually need a "Left Outer Join" can lead to data loss, as any row in your primary table that doesn't have a perfect match in the secondary table will be deleted from the final output entirely.

Tips

To keep your workbook performing quickly, use the "Only Create Connection" option for your source tables. Loading every single table to a worksheet before merging them creates redundant data and increases the file size, which can lead to lag in larger datasets.

If you have more than two tables to merge, you can perform a "chained merge." Once you have merged Table A and Table B, you can stay within the Power Query Editor and select Merge Queries again to bring in Table C. This allows you to build a complex master dataset from multiple disparate sources.

Always clean your data before merging. Use the Trim function (Right-click column > Transform > Trim) in Power Query to remove accidental leading or trailing spaces in your key columns. A cell that contains "ID123 " (with a space) will not match a cell that contains "ID123", causing the merge to fail for that row.

Troubleshooting

If your merged columns are showing null values despite you knowing the data exists in both tables, first check for trailing spaces in your key columns using the Trim tool mentioned above. If that doesn't work, verify the data types. In the Power Query Editor, click the icon to the left of the column header and ensure both are set to the same type (e.g., both "Whole Number").

If the From Table/Range button is greyed out, it means your cursor is not inside an official Excel Table. Select your data and press Ctrl+T to convert the range into a table first.

If the merged table does not update when you change the original data, remember that Power Query does not update in real-time. You must go to the Data tab and click Refresh All to pull the latest changes from the source tables into the merged result.

If you encounter an "Expression.Error: The column 'ColumnName' of the table wasn't found," it means you renamed a column in one of your source tables after you had already performed the merge. Power Query looks for the exact name. To fix this, go to Data > Queries & Connections, right-click your merge query, select Edit, and update the step in the "Applied Steps" pane to reflect the new column name.

Frequently Asked Questions

Can I merge tables from two different Excel files?

Yes. Instead of selecting "From Table/Range," go to Data > Get Data > From File > From Excel Workbook. Select the external file and the specific table or sheet you need, then proceed with the Merge steps as usual.

What is the difference between Merging and Appending?

Merging is like a VLOOKUP; it adds new columns to an existing row based on a match. Appending is like stacking; it adds new rows to the bottom of a table, provided the columns are the same.

Is there a limit to how many tables I can merge?

There is no hard limit to the number of tables you can merge, but very large merges (millions of rows across many tables) can slow down your computer's RAM and increase processing time during the Refresh.

Do I have to use Power Query, or can I use formulas?

You can use XLOOKUP or VLOOKUP, but formulas can become slow and "break" if rows are inserted or deleted. Power Query is more robust, handles larger datasets better, and is easier to audit.

Can I merge tables if they don't have a unique ID?

You can merge based on multiple columns. In the Merge dialog, hold Ctrl and click two or more columns in the first table, then click the corresponding columns in the second table in the same order. This creates a composite key for the merge.