Excel does not have a single function named CASE. The closest built-in options are the SWITCH function (for exact matches) and the IFS function (for range or condition-based logic). If you are looking for a way to evaluate multiple conditions and return different results, you use SWITCH or IFS, not a dedicated CASE function. This guide shows you how to use both, when to pick one over the other, and how to handle common errors.
What You'll Need
- Microsoft Excel 2016 or later (SWITCH and IFS are not available in Excel 2013 or earlier).
- A worksheet with the data you want to evaluate.
- Basic familiarity with entering formulas in a cell.
Step-by-Step
Using SWITCH (Exact Match)
- Identify the cell or value you want to test. For example, cell A2 contains a status code like "A", "B", or "C".
- Click an empty cell where you want the result. Let's use B2.
- Type the SWITCH formula. The syntax is:
=SWITCH(expression, value1, result1, [value2, result2, ..., default]). For our example, type:=SWITCH(A2, "A", "Approved", "B", "Pending", "C", "Rejected", "Unknown"). - Press Enter. Excel evaluates A2. If it equals "A", it returns "Approved"; if "B", "Pending"; if "C", "Rejected"; otherwise, it returns "Unknown" (the default).
- Copy the formula down to other rows if needed.
Using IFS (Conditions or Ranges)
- Decide on your conditions. For example, if a score in A2 is greater than 90, return "A"; greater than 80, "B"; greater than 70, "C"; otherwise "F".
- Click an empty cell. Use B2.
- Type the IFS formula. The syntax is:
=IFS(condition1, result1, condition2, result2, ...). For our example:=IFS(A2>90, "A", A2>80, "B", A2>70, "C", TRUE, "F"). TheTRUEat the end acts as a catch-all for any value that didn't match the earlier conditions. - Press Enter. Excel checks the conditions from left to right and returns the first result whose condition is TRUE.
- Copy down as needed.
Nesting IF as an Alternative
- If you have an older Excel version, you can use nested IF functions:
=IF(A2="A", "Approved", IF(A2="B", "Pending", IF(A2="C", "Rejected", "Unknown"))). - Keep nesting shallow—Excel allows up to 64 nested IFs, but readability suffers quickly. For more than a few conditions, SWITCH or IFS is better.
Using a Lookup Table (Alternative to CASE)
- Create a small table with two columns: one for the code, one for the result.
- Use VLOOKUP or XLOOKUP to return the matching result. For example, if your table is in D1:E4, use
=VLOOKUP(A2, D:E, 2, FALSE). - This is often easier to maintain than a long formula, especially if the list of codes changes.
Common Mistakes
- Using SWITCH for ranges. SWITCH only does exact matches. If you write
=SWITCH(A2, A2>90, "A", ...), it will not work—SWITCH compares A2 to the value TRUE/FALSE, not to the condition result. Use IFS for ranges. - Forgetting the default in SWITCH. If no match is found and you omit the default, Excel returns a #N/A error. Always add a default unless you are certain every possible value is covered.
- Not using TRUE as the final IFS condition. If none of your IFS conditions are TRUE and you don't have a final TRUE, Excel returns #N/A. Add
TRUEas the last condition with a fallback result. - Text vs. number mismatch. If your data has numbers stored as text (e.g., "1" instead of 1), SWITCH or IFS may not match. Check the cell format or use the VALUE function to convert.
- Incorrect order of conditions in IFS. IFS stops at the first TRUE. If you put
A2>70beforeA2>90, a score of 95 will return "C" instead of "A". Always order from most specific to least specific.
Tips
- Use SWITCH when you have a short, fixed list of exact values (like status codes, country codes, or product types). It is cleaner and faster than nested IFs.
- Use IFS when you have ranges or complex conditions (like score bands, date ranges, or multiple criteria). It is more readable than nested IFs.
- Consider a lookup table for long lists. If you have more than five or six conditions, a lookup table with VLOOKUP or XLOOKUP is easier to update and less error-prone.
- Use named ranges for the expression or conditions to make formulas self-documenting. For example, name A2 "Score" and write
=IFS(Score>90, "A", ...). - Test with a few known values before rolling out to a large dataset. Enter edge cases like the highest and lowest possible values.
- Remember that SWITCH and IFS are case-insensitive for text. "a" and "A" are treated the same.
Troubleshooting
#N/A Error
This means no match was found. For SWITCH, add a default value as the last argument. For IFS, add TRUE as the last condition with a fallback result. Check that your values exactly match (including spaces and text case).
#NAME? Error
This usually means you are using an older Excel version that does not support SWITCH or IFS. Check your Excel version (File > Account). If you have Excel 2013 or earlier, use nested IFs instead.
Formula Returns Wrong Result
Check the order of conditions in IFS—the first TRUE wins. For SWITCH, ensure you are comparing the right expression. Also verify that the data in the cell is not formatted as text with a leading apostrophe or extra spaces. Use the TRIM function to clean data: =TRIM(A2).
Formula Works but Copying Down Gives Errors
If you copy a formula down and the cell references shift incorrectly, use absolute references (e.g., $A$2) where needed, especially if you are referencing a fixed lookup table.
Frequently Asked Questions
Does Excel have a CASE function like SQL?
No, Excel does not have a function named CASE. The closest equivalents are SWITCH for exact matches and IFS for condition-based logic. Both were introduced in Excel 2016.
Can I use SWITCH with ranges?
No, SWITCH only does exact matches. For ranges (e.g., score > 90), use IFS or nested IFs.
What is the maximum number of conditions in IFS?
You can enter up to 127 pairs of condition and result in IFS. However, for readability, it is better to keep it under 10 and use a lookup table for more.
Is SWITCH case-sensitive?
No, SWITCH is case-insensitive for text. "A" and "a" are treated as the same.
Can I use a cell range as the expression in SWITCH?
No, the expression must be a single value or a reference to a single cell. If you want to evaluate multiple cells, you need to use a different approach, such as IFS with conditions on each cell, or combine them with AND/OR.
What is the difference between IFS and nested IF?
IFS is a single function that evaluates multiple conditions from left to right. Nested IF puts one IF inside another. IFS is easier to read and less prone to parentheses errors, but nested IF works in older Excel versions.