0
0
Google Sheetsspreadsheet~10 mins

SWITCH function in Google Sheets - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

This table lists fruits in column A and their colors in column B. We will use SWITCH to find the color name for the fruit in A2.

CellValue
A1Fruit
A2Apple
A3Banana
A4Cherry
B1Color
B2Red
B3Yellow
B4Red
C1Color Result
Formula Trace
=SWITCH(A2, "Apple", "Red", "Banana", "Yellow", "Cherry", "Red", "Unknown")
Step 1: SWITCH("Apple", "Apple", "Red", "Banana", "Yellow", "Cherry", "Red", "Unknown")
Cell Reference Map
    A       B       C
1 | Fruit | Color | Color Result
2 | Apple | Red   | [Formula]
3 | Banana| Yellow| 
4 | Cherry| Red   | 
The formula in C2 uses the value in A2 (Apple) to find the matching color.
Result
    A       B       C
1 | Fruit | Color | Color Result
2 | Apple | Red   | Red
3 | Banana| Yellow| 
4 | Cherry| Red   | 
The formula in C2 returns "Red" because the fruit in A2 is "Apple" which matches the first case in SWITCH.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does the SWITCH function return if the value matches the first case?
AThe value for that case
BThe default value
CAn error
DThe next case value
Key Result
SWITCH(expression, case1, value1, case2, value2, ..., default_value) returns the value matching the first case equal to expression or default_value if none match.