Sub topic 6
Turning the Scenario Name into a Number with MATCH
Prerequisites and the purpose of MATCH
This chapter assumes that you know basic spreadsheet formulas, absolute references such as $A$1, and the layout of a simple financial model. You should also understand that an input cell can drive other calculations.
A scenario selector is usually easier for a user to understand when it contains a name such as Base, Upside, or Downside. Spreadsheet functions often need a position number, however. CHOOSE, for example, uses 1 for its first option, 2 for its second option, and so on.
The MATCH function converts the selected scenario name into that position number.
=MATCH($C$3, $B$5:$B$7, 0)This formula searches for the value in C3 within the list B5:B7. The final argument, 0, requires an exact match.
| Cell | Value |
|---|---|
| B5 | Base |
| B6 | Upside |
| B7 | Downside |
| C3 | Upside |
| C4 | `=MATCH($C$3,$B$5:$B$7,0)` |
Because Upside is the second item in the range, C4 returns 2.
How MATCH calculates the index
The basic syntax is:
=MATCH(lookup_value, lookup_array, match_type)lookup_valueis the value to find, such as the selected scenario name.lookup_arrayis the one-row or one-column range to search.match_typecontrols how the search behaves.
Use 0 for scenario names. Exact matching prevents a misspelled or unexpected label from being treated as a nearby match.
| Match type | Meaning | Use for scenario names? |
|---|---|---|
| `0` | Find an exact value | Yes |
| `1` | Find an approximate value in an ascending list | No |
| `-1` | Find an approximate value in a descending list | No |
If C3 contains Upside, this formula returns 2:
=MATCH($C$3, $B$5:$B$7, 0)If C3 contains Growth, which is not in the list, the formula returns #N/A. This error is useful because it exposes a broken selector instead of silently choosing the wrong assumptions.
Linking MATCH to CHOOSE
Once MATCH returns an index, use that index as the first argument of CHOOSE. Suppose the scenario assumptions are arranged in columns E, F, and G:
| Driver | Base | Upside | Downside |
|---|---|---|---|
| Revenue growth | 5% | 10% | 0% |
The live case row can use the index in C4:
=CHOOSE($C$4, E12, F12, G12)When C4 is 1, the formula returns E12. When it is 2, it returns F12. When it is 3, it returns G12.
The complete chain is:
C3: Upside
C4: =MATCH($C$3,$B$5:$B$7,0)
Live revenue growth: =CHOOSE($C$4,E12,F12,G12)The selector is readable, while the index gives the switching formula the numeric position it needs.
Handling errors and checking the switch
A dropdown list should normally prevent invalid names, but formulas can still break if someone pastes over the selector or changes the source list. Add a separate check cell:
=IF(AND(ISNUMBER($C$4),$C$4>=1,$C$4<=3),0,1)This returns 0 when the index is valid and 1 when it is invalid. Include the check in the model's master error check.
You can also display a friendly message around MATCH:
=IFERROR(MATCH($C$3,$B$5:$B$7,0),"Check scenario")Use this only when the result is intended for display. For a calculation input, keeping #N/A visible can make the problem easier to trace.
Exercise
If B5:B7 contains Base, Upside, and Downside, what does =MATCH("Downside",$B$5:$B$7,0) return?
Show answer
It returns 3 because Downside is the third item in the lookup range.