ThisCalculator

Everyday

Merge Single Sheet with Multiple Lookup

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Merge Single Sheet with Multiple Lookup

This article explains how to merge a single sheet with multiple lookup values, a common task in spreadsheet programs like Excel and Google Sheets. You will learn the core techniques using formulas like INDEX/MATCH and XLOOKUP, how to handle multiple criteria, and how to avoid common errors. By the end, you will be able to combine data from different sheets accurately and efficiently.

Formula

When merging a single sheet with multiple lookup values, the core formula is an array formula that checks each row in the lookup table for a match with the target ID. In Excel or Google Sheets, you can use:

=SUM(IF(ISNUMBER(MATCH(id, lookup_range, 0)), 1, 0))

Where:

  • id – the value you are searching for (e.g., a product code or employee ID).
  • lookup_range – the column in the source sheet that contains the IDs (e.g., A1:A50).
  • MATCH – returns the position of the id in the range, or an error if not found.
  • ISNUMBER – converts the match result to TRUE/FALSE.
  • IF – turns TRUE into 1, FALSE into 0.
  • SUM – adds up all the 1s, giving the count of matches.

In the calculator above, the formula counts how many times the given ID appears in the first 50 rows of column A. This is useful for verifying if a lookup will return multiple results.

Worked Example

Suppose you have a sheet named “Sales” with product IDs in column A (A1:A50). You want to know how many times product ID 1001 appears. Using the default values from the calculator:

  1. Lookup ID = 1001
  2. Table rows = 50
  3. The formula checks each row from 1 to 50 for the value 1001.
  4. If it finds 3 occurrences, the result is 3.

For example, if the IDs are: 1001, 1002, 1001, 1003, 1001 – the count is 3. The calculator shows this count, which helps you decide whether to use a simple VLOOKUP (which returns the first match) or a more advanced method to get all matches.

Why Multiple Lookups Are Tricky

Most lookup functions (VLOOKUP, HLOOKUP, LOOKUP) are designed to return only the first match. If your source sheet contains duplicate IDs, you will only get one result, and you might miss important data. This is a common problem when merging customer orders, product inventories, or employee records. To merge a single sheet with multiple lookup values, you need a strategy that handles duplicates or multiple criteria.

How to Merge with Multiple Criteria

When you need to merge data based on more than one condition (e.g., product ID AND region), you can use an array formula with INDEX and MATCH. For example:

=INDEX(return_range, MATCH(1, (criteria_range1=criteria1) * (criteria_range2=criteria2), 0))

This formula works in both Excel and Google Sheets (with CSE in older Excel versions). It checks both conditions simultaneously and returns the corresponding value from the return range. If you need all matches, you can use the FILTER function in newer Excel and Google Sheets:

=FILTER(return_range, (criteria_range1=criteria1) * (criteria_range2=criteria2))

This returns an array of all matching values, which is ideal for merging multiple rows.

Choosing the Right Approach

Your choice depends on your spreadsheet software and your goal:

  • VLOOKUP – simple, but only returns the first match, and the lookup column must be the first column in the range.
  • INDEX/MATCH – more flexible, allows lookup column anywhere, and can handle multiple criteria with array formulas.
  • XLOOKUP – modern replacement, supports multiple criteria natively and can return all matches with the “return multiple” option (in Excel 365).
  • FILTER – best for returning all matching rows, works in Excel 365 and Google Sheets.

For a single sheet merge with multiple lookups, the FILTER function is often the easiest and most powerful. If you are using an older version of Excel, you may need to use array formulas or a pivot table.

Common Problems and Solutions

Here are frequent issues when merging sheets with multiple lookups:

  • #N/A errors – This means no match was found. Check for typos, extra spaces, or number stored as text.
  • Wrong results due to duplicates – Use FILTER or a pivot table to get all matches, not just the first.
  • Performance issues – Array formulas over large ranges can slow down your spreadsheet. Limit the range to the actual data size.
  • Data type mismatch – Ensure IDs are both numbers or both text. Use the TEXT function to convert if needed.

Comparison of Lookup Functions

Function Returns Multiple Criteria All Matches
VLOOKUP First match No (requires helper column) No
INDEX/MATCH First match (or nth with SMALL) Yes (array) No (unless array)
XLOOKUP First match (or all with mode) Yes Yes (Excel 365)
FILTER All matches Yes Yes

Frequently Asked Questions

Can I merge a single sheet with multiple lookup values without formulas?

Yes, you can use Power Query (Get & Transform) in Excel or Google Sheets’ QUERY function. Power Query allows you to merge tables based on multiple columns with a few clicks, and it handles duplicates gracefully. This is often the best approach for large datasets.

Why does VLOOKUP return the wrong value when there are duplicates?

VLOOKUP only returns the first matching row. If you have duplicate IDs, you will only see the first one. To get all matches, use FILTER or a pivot table.

How do I merge two sheets based on two columns (e.g., ID and Date)?

Use an array formula with INDEX/MATCH and a multiplication of conditions, or use FILTER with a similar condition. In Power Query, you can hold the Ctrl key to select multiple columns when merging.

What is the difference between XLOOKUP and VLOOKUP?

XLOOKUP is newer and more flexible: it can search to the left, return multiple matches, and handle errors more gracefully. VLOOKUP is older and has limitations, but is still widely used for compatibility.

Can I merge a sheet with multiple lookup values in Google Sheets?

Yes, Google Sheets supports FILTER, QUERY, and ARRAYFORMULA, which can handle multiple lookups. The QUERY function is especially powerful for merging with SQL-like syntax.

Related

Formula used
in id | Lookup ID | - | 1001 | 0
in t | Table rows | - | 50 | 1
out pace | Matches found | - | count(if(match(id, A1:A50, 0), 1, "")) | 0
out speed | Rows checked | - | t | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.