Home / Guides / Nested IF Statements in Excel

Nested IF Statements in Excel

Excel Functions · Updated June 2026

A nested IF places one IF inside another to test several conditions in sequence. In financial models it assigns ratings, applies tiered rates, or classifies accounts when the logic depends on more than two outcomes. Nested IFs are flexible and need no extra tables, but they grow hard to read fast, which is exactly where modeling errors hide.

Syntax and how it works

A single IF is =IF(logical_test, value_if_true, value_if_false). To handle a third outcome you put another IF in the value_if_false slot: =IF(test1, result1, IF(test2, result2, result3)). Excel evaluates the tests in order and stops at the first one that is true, so the order of branches is the logic.

Because each false branch can hold another IF, you can chain many tests. Modern Excel allows up to 64 nested levels, but readability collapses long before that. The key mental model is a ladder: each rung checks a condition, and falling off the bottom rung yields the final else result.

Worked example: credit rating from a score

A score sits in F1. You want to return a rating: 90 and above is A, 75 to 89 is B, 60 to 74 is C, and anything below 60 is D. Order the tests from the highest threshold down so each one only has to check a single boundary.

  1. Enter =IF(F1>=90, "A", IF(F1>=75, "B", IF(F1>=60, "C", "D"))).
  2. If F1 is 82, the first test F1>=90 is false, so Excel moves to the next IF.
  3. The second test F1>=75 is true, so the formula returns B and stops.
  4. Because the ladder runs high to low, you never have to write a compound AND for each band.
Score (F1)ResultBranch that fired
95Afirst test
82Bsecond test
68Cthird test
50Dfinal else

A score of 82 stops at the second rung and returns B.

Why analysts use them and where they fit

Nested IFs are the right tool when the outcomes are few, the logic is unlikely to change, and you do not want to maintain a separate lookup table. They keep the rule inside the formula, which is convenient for a quick classification column.

They start to cost more than they save once the branches multiply or the thresholds become assumptions someone will want to tune.

Common pitfalls in models

Branch order is the top trap. If you test F1>=60 before F1>=90, every score above 60 returns the first matching band and the higher bands never fire. Always order overlapping comparisons from the strictest boundary down.

Mismatched parentheses are the second trap. Each nested IF adds a closing parenthesis, and deep ladders are easy to miscount. Hardcoded thresholds buried in the formula are the third: they are invisible to a reviewer and tedious to update across a column, so promote them to assumption cells.

Do it in one click

Formula Trace

Formula Trace maps the cells feeding a nested IF so you can see which inputs drive each branch of the ladder.

Get ModelMint See how it works

FAQ

How many IFs can you nest in Excel?

Modern Excel allows up to 64 nested IF functions in one formula. In practice readability and error risk make anything past three or four levels a poor choice, and IFS or a lookup table is usually clearer.

Why does my nested IF return the wrong band?

Most often the comparison tests are in the wrong order. For overlapping thresholds, order the tests from the strictest boundary down so the first true test is the correct one, since Excel stops at the first match.

When should I replace a nested IF with IFS?

Use IFS once you have more than about three conditions or when the nesting becomes hard to read. IFS lists each condition and result as a flat pair, which removes the deep parentheses and makes the logic easier to audit.