Power Query: Compare two tables in Excel
Comparing two tables is a common task in Excel. You may want to identify items that are the same, different, or missing from the columns. For example, we have two similar tables with the same column names, but, there are some differences between the two tables. Now, you want to find the differences for comparing each row of the two tables as below screenshots shown. This tutorial will introduce how to use the Power Query feature to deal with this task in Excel.
Please follow the step-by-step tutorial to achieve this job:
Creating queries from the two tables
1. Select the first table that you want to compare, then, in Excel 2019 and Excel 365, click Data > From Table/Range, see screenshot:
Note: In Excel 2016 and Excel 2021, click Data > From Table, see screenshot:
2. Then, in the opened Power Query Editor window, click Close & Load > Close & Load To, see screenshot:
3. In the following Import Data dialog box, select Only Create Connection option, and then, click OK button to close the dialog. see screenshot:
4. Repeat the same step 1- 3 to create a connection for the second table. Finally, you should have two queries corresponding with your tables. And you can see the two tables in the Queries & Connections pane. See screenshot:
Joining queries to compare two tables
After creating queries from the two tables, next, you should join the queries into a new table.
5. Please go on clicking Data > Get Data > Combine Queries > Merge in Excel 2019 and Excel 365, see screenshot:
Note: In Excel 2016 and Excel 2021, click Data > New Query > Combine Queries > Merge, see screenshot:
6. In the popped-out Merge dialog box, please do the following operations:
- Select the first and second table names from the drop down list separately.
- Select the columns that you want to compare from the two tables. (To select multiple columns, please press Ctrl key to select them one by one) In this example, I will select all columns to compare.
- And then, select Full Outer (all rows from both) under the Join Kind drop down.
- At last, click OK button.
7. Then, a new column for the second table is inserted next to the first table:
- Click the Expand icon next to the column title.
- Check Expand option.
- Check the columns that you want to insert into the comparison table.
- Finally, click OK button.
8. Then, the data of the second table is populated at once. And now, please click Home > Close & Load > Close & Load to load the data into a new worksheet. See screenshot:
9. Now, you can find the different rows of the two tables quickly and easily. The rows contain the same data of the specified columns are listed in the same row, and the empty columns indicate rows with different data. See screenshot:
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- 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!