Decisions with IF · About 6 minutes
More than two results with nested IF
One IF gives two results. For three, put a second IF in the FALSE part of the first. This is called a nested IF.
=IF( reads as "if B2 is 75 or more, Distinction; otherwise, if it's 35 or more, Pass; otherwise Fail".
Check the highest band first. The sheet stops at the first TRUE question, so a mark of 82 would stop at "35 or more" if that came first. Each IF needs its own closing parenthesis.
Part of Plus
Free during our founding launch: sign in to unlock this lesson's exercises, the timed practice sets and the rest of Plus. The free lessons stay free, with no account needed.
What Nested IF does
One IF gives one of two results. A nested IF puts a second IF inside the first, so you can sort values into three or more bands, like grades A, B and C.
This is the classic if formula for grades. The sheet asks each question in turn and stops at the first one that is TRUE, so the order of the questions decides the answer.
How to write Nested IF
=IF(
- logical_test
- The question, like
B2>=80. It is either TRUE or FALSE. - value_if_true
- What to show when the answer is TRUE, like
"A". - value_if_false
- What to show when it is FALSE. In a nested IF, this is where the next IF goes. Leave it out and the cell shows FALSE.
Nested IF worked example
80 or more is an A, 60 or more is a B, and anything lower is a C. In C2 to C5, give each grade.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Score | Grade |
| 2 | Ana | 86 | A |
| 3 | Ben | 64 | B |
| 4 | Cy | 59 | C |
| 5 | Dee | 80 | A |
=IF( B2>=80, "A", IF( B2>=60, "B", "C"))If B2 is 80 or more, show A; otherwise, if it's 60 or more, show B; otherwise show C. That gives A for 86, B for 64, C for 59 and A for 80.Common Nested IF mistakes
Every top score gets the middle grade
Ask about the highest band first. If B2>=60 comes first, 86 stops there and gets a B. Put B2>=80 at the front.
The sheet says the formula has a problem
Count the closing brackets. Each IF needs its own, so two IFs end with )) and three end with ))).
Some scores show FALSE
The last IF has no value_if_false. Add a final result for everything left over, like "C".
Nested IF, IFS or a lookup?
A nested IF works in every version of Excel and in Google Sheets. Excel allows up to 64 IFs inside each other, but past three or four bands the brackets get hard to read.
IFS does the same job without nesting, in Excel 2019 and later and in Google Sheets. For many bands, a small table with VLOOKUP in approximate match is easier to change later.
Questions people ask
How do I write an IF formula with 3 results?
Put a second IF in the false part of the first: =IF(. Each extra result adds another IF.
How many IFs can you nest in Excel?
Up to 64, but past three or four a lookup table is easier to read and fix.
What's the difference between nested IF and IFS?
IFS lists each test and result in order with no nesting: =IFS(. It's in Excel 2019 and later and Google Sheets.
Why does my nested IF give the wrong grade?
The tests are in the wrong order. The formula stops at the first true test, so check the highest band first.
Should I use IF or VLOOKUP for grade bands?
For three or so bands, nested IF is fine. For more, or bands that change, a sorted table with VLOOKUP and TRUE is easier to keep up to date.