Sub topic 3
Handling Several Outcomes with Nested IF
Assume you can enter formulas, use cell references such as B2, and copy formulas down a column. A nested IF places one IF inside another so a formula can return more than two outcomes.
Handling several outcomes with nested IF
Test conditions from the highest threshold downward. Excel returns the result for the first true test and stops checking.
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","F")))This formula returns A for 90 or more, B for 80–89, C for 70–79, and F for lower scores.
A cleaner option: the IFS function
IFS tests condition-result pairs in order and is easier to read when there are many outcomes.
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")The final TRUE provides a default result. IFS is available in Excel 2019 and later and in Microsoft 365.
Detecting and handling blank cells
Check for a blank before calculating. An empty string, "", displays as an empty cell.
=IF(A2="","",B2*C2)This prevents a result from appearing until A2 contains a value.
Preventing errors such as division by zero
Guard a division with a test for zero:
=IF(C2=0,"",B2/C2)The formula returns an empty result when C2 is zero.
Common mistakes and how to fix them
| Mistake | Fix |
|---|---|
| Text is missing quotes | Write `"Pass"`, not `Pass` |
| Tests use the wrong order | Put higher thresholds first |
| A condition uses `=` instead of `>=` | Choose the operator that matches the rule |
| A nested formula has missing parentheses | Check each `IF` has three arguments |
Exercise
Write a formula that returns "High" for 100 or more, "Medium" for 50–99, and "Low" otherwise.
Show answer
=IF(B2>=100,"High",IF(B2>=50,"Medium","Low"))