How do I write a formula with more than one IF condition?
A nested IF puts one IF formula inside another to test conditions in sequence: =IF(condition1, result1, IF(condition2, result2, result3)). Beyond two or three levels, IFS or a lookup table is almost always easier to read and maintain.
Formula (Excel and Google Sheets)
=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","D")))Each IF checks one condition and gives two outcomes: what to return if it is true, and what to return if it is false. Nesting means the "false" outcome of one IF is itself another IF, so you keep testing conditions until one matches. The example above assigns a letter grade by checking, in order, whether a score is 90+, then 80+, then 70+, and otherwise falling through to the last value.
The main risk with nested IFs is readability: past three or four levels deep, a formula becomes hard to audit and easy to break when someone edits it later. Where your spreadsheet program supports it, IFS(condition1, result1, condition2, result2, ...) reads the same conditions in a flatter, more readable list.
Step by step
- 1
Order conditions from most to least specific
Put the narrowest or highest-priority condition first, since the formula stops at the first TRUE it finds.
- 2
Nest the next IF in the false slot
Each additional condition goes inside the false argument of the previous IF.
- 3
Add a final catch-all value
The innermost IF's false result is what everything that did not match falls through to.
- 4
Consider IFS for readability
If your program supports IFS, rewrite three or more nested IFs as a flat IFS list to make future edits safer.
Common questions
How many IFs can I nest?
Excel allows up to 64, but readability breaks down well before that. Three is a reasonable practical limit before switching to IFS or a lookup table.
What is a simpler alternative to deeply nested IFs?
IFS() for flat condition lists, or a small lookup table paired with VLOOKUP/INDEX MATCH for tiered results like grade bands or pricing tiers.
Related formulas
How to Use INDEX and MATCH Together in Excel and Google Sheets
RelatedHow to Use COUNTIF and COUNTIFS in Excel and Google Sheets
RelatedHow to Use Conditional Formatting to Highlight Cells Automatically
From the blogHow to Make Sense of Your Spreadsheet Data Without Being an Analyst
Want a formula written for your exact spreadsheet, not a generic example?
Try the free formula generator