Approximate match: bands and grades
Give each student a grade from the boundaries in E2:F7. Most scores, like 64, aren't in the table at all.
keyboard Typing formulas is easiest on a computer with a keyboard.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Student | Score | Grade | From | Grade | ||
| 2 | Oscar | 64 | 0 | F | |||
| 3 | Kofi | 70 | 40 | E | |||
| 4 | Quinn | 79 | 50 | D | |||
| 5 | Elif | 80 | 60 | C | |||
| 6 | Mateo | 78 | 70 | B | |||
| 7 | Nadia | 61 | 80 | A | |||
| 8 | Jamal | 51 | |||||
| 9 | Victor | 22 | |||||
| 10 | |||||||
| 11 | |||||||
| 12 | |||||||
| 13 |
How VLOOKUP and XLOOKUP works
What is an approximate match?
An exact match only finds values that are in the table. Bands work differently: a score of 67 isn't in a grade table, but it falls between the 60 and 70 boundaries, so it gets the grade for 60. An approximate match finds the largest value that is less than or equal to what you look up.
=VLOOKUP(B2,$E$2:$F$7, 2, TRUE) How should the band table look?
- One row per band, with the lowest value of each band in the first column: 0, 40, 50...
- Sorted from smallest to largest. On unsorted data an approximate match quietly returns wrong answers.
- Start at the lowest possible value (0 here). A score below the first band gives #N/A.
Why
TRUE?TRUEasks for an approximate match.VLOOKUPalso does one when the last part is left out, which is why forgettingFALSEin an ordinary lookup gives wrong answers. WriteTRUEso the next reader knows it is on purpose.What else uses bands?
Tax rates, commission levels, shipping prices by weight and discounts by order size. In
XLOOKUP, use -1 as the match mode for "exact match or next smaller":=XLOOKUP(B2,$E$2:$E$7,$F$2:$F$7,,-1).
Know someone fighting with a spreadsheet? Send them this page.