Evaluate a value against multiple conditions and return a corresponding result
Scenario | Formula | Remarks |
---|---|---|
Convert student scores into letter grades | =SWITCH(A2, 90, "A", 80, "B", 70, "C", 60, "D", "F") | If A2 = 90, it returns "A" |
Convert a number (1-7) to a weekday name | =SWITCH(A2, 1, "Sunday", 2, "Monday", 3, "Tuesday", 4, "Wednesday", 5, "Thursday", 6, "Friday", 7, "Saturday", "Invalid") | If A2 = 3, it returns "Tuesday" |
Convert an amount based on currency selection | =SWITCH(A2, "USD", B2*280, "EUR", B2*300, "GBP", B2*350, "Invalid Currency") | If A2 = "USD" and B2 = 10, it returns 2800 |
Apply discounts based on product category | =SWITCH(A2, "Electronics", B2*0.90, "Clothing", B2*0.80, "Toys", B2*0.85, B2) | If A2 = "Electronics" and price B2 = 1000, it returns 900 |
Convert "Hello" into different languages | =SWITCH(A2, "English", "Hello", "Spanish", "Hola", "French", "Bonjour", "Unknown Language") | If A2 = "French", it returns "Bonjour" |
Convert Celsius to Fahrenheit and vice versa | =SWITCH(A2, "Celsius to Fahrenheit", B2*9/5+32, "Fahrenheit to Celsius", (B2-32)*5/9, "Invalid Conversion") | If A2 = "Celsius to Fahrenheit" and B2 = 25, it returns 77 |
Convert ratings (1-5) into stars | =SWITCH(A2, 1, "★☆☆☆☆", 2, "★★☆☆☆", 3, "★★★☆☆", 4, "★★★★☆", 5, "★★★★★", "Invalid Rating") | If A2 = 4, it returns "★★★★☆" |