FxFormula Drills

Nested IF

A nested IF puts another IF in the true branch or the false branch so one formula can return more than two results. For letter grades, test the highest cutoff first: 90 and above is A, otherwise test 80, otherwise C. IFS does the same job as a list of pairs in Excel 2019 and later and in Google Sheets. Nested IF remains the formula that also runs in older Excel.

Syntax

Nested IF

IF(test1, result1, IF(test2, result2, result3))

The outer IF handles the first test. Its false branch is another IF. The innermost value is the final else. Test the highest cutoff first when the bands are 'at least N'.

IFS

IFS(test1, result1, test2, result2, TRUE, default)

Pairs are checked from left to right and the first true test wins. IFS has no separate else. A final TRUE, default pair is the usual fallback. If nothing matches and you omit that pair, IFS returns #N/A.

Comparison

QuestionNested IFIFS
ShapeIF inside IFA flat list of tests and results
Final elseThe last argument of the innermost IFA pair whose test is TRUE, if you add one
Nothing matched and there is no elseYou always have an else if you closed the formula#N/A
Order of testsHighest cutoff first for 'at least' bandsSame. First true pair wins
Older ExcelWorksExcel 2019 or later, or Microsoft 365. Also Google Sheets

Worked examples

Letter grades with the high cutoff first

90 and above is A. 80 and above is B. Anything else is C. 91, 82, and 64 are the three scores. Both formulas return the same letters when the tests are in that order.

Scores in A2:A4 are 82, 64, and 91. A5 is 49.
RowAB
1ScoreRegion
282East
364West
491East
549North
  • =IF(A2>=90,"A",IF(A2>=80,"B","C")) → B
  • =IF(A3>=90,"A",IF(A3>=80,"B","C")) → C
  • =IF(A4>=90,"A",IF(A4>=80,"B","C")) → A
  • =IFS(A2>=90,"A",A2>=80,"B",TRUE,"C") → B
  • =IFS(A4>=90,"A",A4>=80,"B",TRUE,"C") → A

82 fails the 90 test and passes the 80 test, so it is a B. 64 fails both cutoffs and lands on C. 91 passes the first test and is an A. The nested IF's innermost "C" is the else. IFS uses TRUE as that else. If you tested >=80 before >=90, an A score would become a B, because 91 is also at least 80 and the first true test would win.

When to use which

Use a nested IF for two or three bands in any Excel

Letter grades and shipping tiers with a couple of cutoffs are readable if you test the top band first and indent the formula in your head as you count parentheses. The grade drill practices this.

Switch to IFS when the list is getting long and the file can use it

Each extra band in a nested IF adds another IF and another closing parenthesis. IFS keeps one pair per band. Use it in Excel 2019 or later, Microsoft 365, and Google Sheets.

Stop nesting when the tests are not an ordered scale

A region, a status, and a score that combine into one bonus are AND and OR inside a single IF, not three layers of IF. Nesting is for different results, not for extra requirements on one result.

Common mistakes

Testing the low cutoff first

IF(A2>=80, "B", IF(A2>=90, "A", "C")) labels 91 as B, because 91 meets the first test and the A test never runs. High cutoff first.

A missing parenthesis

Each IF opens one parenthesis. The formula needs the same number of closing parentheses as opening ones. Excel colors them while you edit. If the formula will not enter, count again.

A final else that is another test by accident

The last value of the innermost IF is not tested. If you needed another cutoff, that value has to be an IF, not a bare letter that you hoped would mean 'else if'.

Using nested IF to mean AND

IF(A2>=70, IF(B2="East", "Bonus", "No"), "No") works, but AND is the sentence you meant and it is easier to read. Save nesting for different outputs.

Versions and compatibility

Nested IF works in every Excel version and in Google Sheets. Very old Excel limited how deep the nesting could go. Two or three levels, as in the grade example, are safe everywhere.

IFS requires Excel 2019, Excel 2021, Excel 2024, Microsoft 365, or Google Sheets. In Excel 2016 it returns #NAME?.

The comparison page for IFS and nested IF uses a shipping tier so you can see the TRUE fallback next to the innermost else.

Practice on Formula Drills

Free drills are open with no account. Premium drills show the problem to everyone and grade the sheet for subscribers.

Free exercises

Premium exercises

Function pages

FAQ

How many IF functions can I nest?

Modern Excel allows a deep nest, and you should stop long before that limit. Three bands are comfortable. Beyond that, IFS or a lookup table is easier to change when a cutoff moves.

Should the else be in quotes?

Text results are quoted, including the final else: "C". Numbers are not quoted. A quoted number is text and will not sum later.

Can the true branch be nested too?

Yes. Nesting in the true branch is how you split a group that already passed the outer test. For ordered cutoffs, nesting in the false branch, as in the grade example, is the usual shape.

What if two bands overlap on purpose?

They should not. 'At least 80' includes 'at least 90'. The order of tests is what makes them exclusive. A lookup table of the minimum score for each grade is the other way to express the same bands, with VLOOKUP approximate match.