Sub topic 3
Exact and approximate match: why the last argument matters
This chapter assumes that you can enter formulas in Google Sheets and understand cell references such as A2:C100. You should also know absolute references, such as $F$2:$G$6, and how to reference another sheet.
VLOOKUP has two matching behaviors
VLOOKUP searches for a key in the first column of a range. It then returns a value from another column in the same row.
Its syntax is:
=VLOOKUP(search_key, range, index, [is_sorted])The last argument, is_sorted, controls how Sheets matches the key:
| Last argument | Matching behavior | Data requirement |
|---|---|---|
| `FALSE` | Exact match only | The lookup column does not need to be sorted |
| `TRUE` | Approximate match | The lookup column must be sorted from smallest to largest |
If you omit the last argument, Google Sheets treats it as TRUE. This default is a frequent source of incorrect results.
Exact match with `FALSE`
Suppose this product table is in A2:C100:
| Product ID | Product name | Price |
|---|---|---|
| P-101 | Cable | 8.50 |
| P-102 | Stand | 24.00 |
| P-103 | Webcam | 49.00 |
To find the price for product P-102, use:
=VLOOKUP("P-102", A2:C100, 3, FALSE)The formula searches for the complete text P-102 in column A. It returns the value from column 3 of the matching row, which is 24.00.
Use exact matching for identifiers such as:
- Product IDs
- Employee numbers
- Invoice numbers
- Email addresses
- Account codes
You can reference a cell instead of entering the key directly:
=VLOOKUP(E2, A2:C100, 3, FALSE)If E2 contains P-102, the result is the matching price. If the key is absent, the formula returns #N/A.
Why omitting `FALSE` is risky
These two formulas do not mean the same thing:
=VLOOKUP(E2, A2:C100, 3, FALSE)=VLOOKUP(E2, A2:C100, 3)The second formula uses approximate matching because the last argument is omitted. If the first column is not sorted, Sheets may return an unrelated value or an error. Even when the data happens to be sorted, a key that is not present may produce a nearby row rather than an obvious failure.
Approximate match with `TRUE`
Approximate matching is useful when the first column represents thresholds. For example, suppose F2:G6 contains shipping tiers:
| Minimum weight | Shipping class |
|---|---|
| 0 | Letter |
| 1 | Small parcel |
| 5 | Medium parcel |
| 10 | Large parcel |
| 25 | Freight |
The minimum weights must be sorted in ascending order. If B2 contains 7, use:
=VLOOKUP(B2, $F$2:$G$6, 2, TRUE)The result is Medium parcel. The formula finds the largest threshold that is less than or equal to 7. It does not require an exact value of 7 in the first column.
Approximate matching works well for:
- Tax brackets
- Discount levels
- Shipping bands
- Commission rates
- Performance grades
The $ signs keep the tier range fixed when you copy the formula to other rows.
caption: How VLOOKUP chooses an approximate match
alt: A flowchart showing a lookup value moving through sorted thresholds and selecting the largest threshold that does not exceed it.
flowchart TD
A[Lookup value: 7] --> B{Find largest threshold <= 7}
B --> C[Threshold 0]
B --> D[Threshold 1]
B --> E[Threshold 5]
E --> F[Return Medium parcel]
B -.-> G[Threshold 10 is too large]Choosing the matching mode
Use this rule:
- Choose
FALSEwhen the key must already exist. - Choose
TRUEwhen the table contains sorted boundaries and you want the closest lower boundary.
If a threshold table is unsorted, approximate VLOOKUP is unsafe. Sort the table first or use another lookup approach designed for the required matching behavior.
Exercise
What result can =VLOOKUP(7, F2:G6, 2, TRUE) return when the first column contains 0, 1, 5, 10, and 25 in ascending order?
Show answer
It returns the value from the row with threshold 5, because 5 is the largest threshold less than or equal to 7.