Basic IF Formula — Quick Recap
IF syntax
=IF(condition, value_if_true, value_if_false)
=IF(A2>100, "Over budget", "Within budget")
IF With AND — Both Conditions Must Be True
Use AND() to require ALL conditions to be true before returning the true value:
IF AND example
=IF(AND(A2="East", B2>1000), "Bonus", "No bonus")
IF With OR — Either Condition Can Be True
Use OR() when ANY of the conditions being true is enough:
IF OR example
=IF(OR(A2="East", A2="West"), "Active region", "Inactive")
Nested IF — Multiple Different Outcomes
When you have 3+ possible outcomes, nest IF formulas inside each other:
Nested IF — grade calculator
=IF(A2>=90,"A", IF(A2>=80,"B", IF(A2>=70,"C", IF(A2>=60,"D","F"))))
Nested IF formulas become difficult to read and debug beyond 3-4 levels. Excel supports up to 64 levels of nesting, but you should switch to IFS at 3+ conditions.
IFS Function — Cleaner Alternative to Nested IF
IFS evaluates conditions in order and returns the value for the first true condition. Much easier to read than nested IF:
IFS grade calculator — same result, cleaner
=IFS(A2>=90,"A", A2>=80,"B", A2>=70,"C", A2>=60,"D", TRUE,"F")
Always include TRUE as the last condition in IFS — it acts as a catch-all "else" clause. Without it, IFS returns #N/A if none of the conditions match.
Common Mistakes With Nested IF
- Forgetting the catch-all at the end: if no condition matches and there is no final else, you get FALSE or an error
- Conditions out of order: always go from highest to lowest (>=90, >=80, >=70) — not random order
- Too many levels: switch to IFS or SWITCH for 3+ conditions
- Missing closing brackets: count your open brackets and make sure each has a matching close
FAQ
Frequently Asked Questions
How do I write an IF formula that checks two conditions in Excel?▾
Use IF with AND: =IF(AND(condition1, condition2), true_value, false_value). Example: =IF(AND(A2>50,B2="Yes"),"Qualified","Not qualified") returns Qualified only if A2>50 AND B2 is Yes.
What is the difference between nested IF and IFS in Excel?▾
Nested IF puts IF formulas inside each other: =IF(c1,v1,IF(c2,v2,IF(c3,v3,default))). IFS lists conditions in sequence: =IFS(c1,v1,c2,v2,TRUE,default). IFS is available in Excel 2019+ and Google Sheets. It is cleaner and easier to maintain for 3+ conditions.
How many conditions can I have in a nested IF?▾
Excel supports up to 64 levels of nested IF. In practice, anything beyond 3-4 levels becomes very difficult to read and debug. For many conditions, use IFS, SWITCH, or VLOOKUP on a lookup table instead.
How do I generate complex IF formulas automatically?▾
Use ExcelForm at excelform.xyz — describe your logic in plain English, for example: 'if score is 90 or above return A, 80-89 return B, 70-79 return C, below 70 return F'. ExcelForm generates the correct IF, IFS or SWITCH formula automatically.