To join data in Excel, you can use the XLOOKUP or VLOOKUP functions for simple matches, or Power Query for merging large datasets. Joining data allows you to combine information from two different tables or sheets based on a common identifier, such as an ID number or an email address, so you don't have to manually copy and paste values.
What You'll Need
- Two sets of data (tables or ranges) that share at least one common column (the "unique identifier").
- The unique identifier must be formatted identically in both sets (e.g., both must be numbers or both must be text).
- A version of Excel that supports the function you choose (XLOOKUP is available in Microsoft 365 and Excel 2021 or later).
Step-by-Step
Depending on your goal, choose one of the following three methods. Note that menu labels may differ slightly based on your version of Excel or region.
Method 1: Using XLOOKUP (Best for Modern Excel)
- Click the cell where you want the joined data to appear.
- Type
=XLOOKUP(. - Click the cell in your current table that contains the unique identifier you are searching for (the "lookup value").
- Type a comma, then go to the second table and select the column that contains the unique identifiers.
- Type another comma, then select the column in the second table that contains the data you actually want to retrieve (the "return array").
- Close the parentheses
)and press Enter. - Drag the fill handle (the small square at the bottom-right of the cell) down to apply the formula to the rest of your list.
Method 2: Using VLOOKUP (For Older Excel Versions)
- Ensure the unique identifier is in the leftmost column of your second table.
- Click the cell where you want the joined data to appear and type
=VLOOKUP(. - Select the lookup value (the identifier in your first table).
- Type a comma, then select the entire range of the second table, starting from the identifier column and extending to the column containing the data you want.
- Type a comma, then enter the column index number. For example, if the data you want is in the third column of the range you selected, type
3. - Type another comma and then type
FALSEto ensure you only get an exact match. - Close the parentheses
)and press Enter.
Method 3: Using Power Query (Best for Large Datasets)
- Select any cell within your first data set and go to the Data tab, then select From Table/Range. If your data isn't a table, Excel will prompt you to create one.
- Once the Power Query Editor opens, select Close & Load > Close & Load To... and choose Only Create Connection.
- Repeat steps 1 and 2 for your second data set.
- Go to the Data tab > Get Data > Combine Queries > Merge.
- In the Merge window, select your first table from the top dropdown and your second table from the bottom dropdown.
- Click the unique identifier column in both table previews to highlight them.
- Under Join Kind, select Left Outer (this keeps all rows from the first table and adds matching values from the second). Click OK.
- In the Power Query Editor, you will see a new column containing "Table" values. Click the small double-arrow icon in the column header.
- Uncheck "Use original column name as prefix" and select only the columns you want to join. Click OK.
- Select Close & Load to return the joined data to a new Excel worksheet.
Common Mistakes
- Mismatched Data Types: Trying to join a column formatted as "Text" with a column formatted as "Number." Even if they look the same, Excel will treat them as different values.
- Hidden Spaces: Leading or trailing spaces in a cell (e.g., "ID101 " vs "ID101") will cause lookup functions to fail.
- Incorrect VLOOKUP Column Index: Counting the column index starting from the whole sheet rather than starting from the leftmost column of the selected range.
- Absolute vs. Relative References: Forgetting to use dollar signs (e.g.,
$A$2:$B$100) when using VLOOKUP or XLOOKUP in a range, which causes the reference to shift as you drag the formula down.
Tips
- Convert to Tables: Press
Ctrl + Tto turn your data ranges into official Excel Tables. This makes your formulas dynamic, meaning they update automatically when you add new rows. - Use TRIM: If you suspect hidden spaces, use the
=TRIM()function on your identifier columns before joining. - XLOOKUP over VLOOKUP: Whenever possible, use XLOOKUP. It is more flexible because the identifier column does not have to be the first column in the range.
- Power Query for Repeat Tasks: If you have to join the same reports every week, use Power Query. Once the merge is set up, you only need to click Data > Refresh All to update the joined list.
Troubleshooting
If your join is not working as expected, try these steps in order:
- Check for #N/A Errors: This usually means no match was found. Double-check that the identifier actually exists in both tables.
- Verify Formatting: Select the identifier columns in both tables, go to the Home tab, and ensure the Number Format dropdown is the same for both (e.g., both set to "General" or "Text").
- Remove Extra Spaces: Use the Find and Replace tool (
Ctrl + H) to replace all spaces with nothing if your identifiers should not contain spaces. - Check Range References: If you are using VLOOKUP or XLOOKUP without Tables, ensure your range references are absolute (using
$) so they don't move when you copy the formula.
Frequently Asked Questions
Can I join more than two tables at once?
Yes, but not with a single XLOOKUP or VLOOKUP. You can either nest multiple lookup functions or use Power Query to perform multiple merges sequentially.
What is the difference between a Left Join and an Inner Join?
A Left Join (the default in most Excel merges) keeps all records from the first table regardless of whether a match exists in the second. An Inner Join only keeps rows where the identifier is present in both tables.
Why is my VLOOKUP returning the wrong data?
This usually happens because the fourth argument is set to TRUE (approximate match) instead of FALSE (exact match). Ensure your formula ends with , FALSE).
Can I join data from two different Excel files?
Yes. You can reference another workbook in an XLOOKUP formula, or use Power Query's Get Data > From File > From Excel Workbook to connect tables from separate files.
What should I do if my unique identifier is not actually unique?
Lookup functions like XLOOKUP and VLOOKUP only return the first match they find. If you have duplicate identifiers, you should use Power Query to merge the data, which will create multiple rows for each match.