Excel Nested IF Statements: How to Use Them With Examples
Excel nested IF statements let you test more than one condition in a single formula and return a different result for each outcome. Instead of writing several separate formulas, you place one IF function inside another, so Excel works through your conditions in order until it finds the first one that is true. This technique is useful for grading, pricing bands, commission tiers, status labels, and any task where a simple yes-or-no test is not enough.
In this guide, you will learn what a nested IF statement is, how its syntax works, how to build one step by step, and how to avoid the mistakes that most often cause errors. By the end, you will be able to write, read, and fix nested IF formulas with confidence.
What Is a Nested IF Statement?
A nested IF statement is an IF function that contains another IF function as one of its results. The basic IF function has three parts: a logical test, a value to return if the test is true, and a value to return if it is false. The syntax is =IF(logical_test, value_if_true, value_if_false).
When you nest IF functions, the value_if_false argument becomes another complete IF function. Excel checks the first condition. If it is true, it returns the first result and stops. If it is false, it moves to the next IF function and checks the next condition. This chain continues until a condition is true or until the final fallback value is reached.
For example, a formula that assigns a grade might first check whether a score is at least 90, then whether it is at least 80, then whether it is at least 70, and finally return a fail grade if none of those tests pass. Each test narrows the range, and the order of the tests matters. If you test the conditions in the wrong order, Excel may return the wrong grade, because it stops at the first true test.
Nested IF Syntax Explained
The general pattern for a nested IF with three conditions looks like this: =IF(condition1, result1, IF(condition2, result2, IF(condition3, result3, fallback))). Notice that every IF function opens with a parenthesis and that the closing parentheses at the end must match the number of IF functions you opened. Forgetting a closing parenthesis is one of the most common causes of formula errors.
You can nest IF functions in the value_if_true argument as well, but most everyday formulas nest in the value_if_false argument, because that creates a clear sequence: if not this, then check that. Keeping the chain in one direction also makes the formula easier to read and easier to audit later.
Step-by-Step: Build a Nested IF Formula for Grades
Suppose you have student scores in column B, starting in cell B2, and you want grades in column C. Follow these steps to build the formula correctly the first time.
Step 1: Decide the order of your conditions. Start with the highest threshold and work down. For grades, that means 90 first, then 80, then 70, then 60. If you start with 60, every score above 60 would match that test first and you would never reach the higher grades.
Step 2: Click the cell where the result should appear, for example C2, and type an equals sign. Type IF, then an opening parenthesis, then your first test, such as B2>=90. After a comma, type the result for that test in quotation marks, such as “A”.
Step 3: After the comma that follows “A”, start the next IF function instead of typing a final result. Type IF(B2>=80,”B”, and continue in the same way for the next bands. A complete example is: =IF(B2>=90,”A”,IF(B2>=80,”B”,IF(B2>=70,”C”,IF(B2>=60,”D”,”F”)))).
Step 4: Press Enter and check the result against a few known scores. Test a score of 95, a score of 85, a score of exactly 80, and a score of 55. Boundary values are important, because a test that uses > instead of >= will give a different result for a score that sits exactly on the boundary.
Step 5: Copy the formula down the column by dragging the fill handle in the bottom-right corner of the cell, or by double-clicking that handle. Check the first and last rows after copying, to make sure the cell references moved correctly. If you need a fixed reference, such as a threshold stored in another cell, use a dollar sign, for example $E$2, to lock that reference.
More Practical Nested IF Examples
Nested IF statements are not only for grades. In a sales worksheet, you might assign a commission rate based on total sales: 15 percent for sales above 50,000, 10 percent for sales above 25,000, 5 percent for sales above 10,000, and no commission below that level. The formula follows the same pattern, starting with the largest threshold first.
In a stock or inventory sheet, you might label items as “In Stock”, “Low Stock”, or “Out of Stock” based on quantity. For example, =IF(A2=0,”Out of Stock”,IF(A2<10,”Low Stock”,”In Stock”)) checks for zero first, because a zero quantity would also be less than 10 and would otherwise be mislabelled as low stock. Order matters here just as it does for grades.
For data work, nested IF statements often sit alongside other tools. If you are cleaning a worksheet before applying a nested IF, you may find our guide to removing duplicates in Excel useful, and if you later need to filter results by condition, see our guide to the Excel FILTER function.
Nested IF vs IFS vs VLOOKUP
Choosing the right tool saves time and reduces errors. The table below compares three common approaches for returning a value based on a condition or a range.
| Method | Best for | Main advantage | Main drawback |
|---|---|---|---|
| Nested IF | A short chain of conditions in one formula | Works in older Excel versions | Hard to read after four or five levels |
| IFS function | Many conditions without nesting | Flatter and easier to read | Not available in very old Excel versions |
| VLOOKUP or XLOOKUP | Long lists or lookup tables | Easy to update by changing the table | Needs a separate table and correct range |
As a rule, use a nested IF for two to four outcomes, use IFS when you have many simple conditions, and use a lookup when the thresholds or labels change often. If a colleague will need to maintain your workbook, a lookup table is usually the clearest option, because the logic is visible in cells rather than hidden inside a long formula.
Common Errors and How to Fix Them
The most frequent error is a missing or extra parenthesis. If Excel shows a message about the formula, count the opening and closing parentheses, or use the formula bar and Excel’s colour coding to match each pair. Another common problem is text that is not in quotation marks: labels such as A or Pass must be written as “A” or “Pass”, while numbers should not be in quotation marks unless you want them treated as text.
A second problem is testing conditions in the wrong order, which usually produces results that look plausible but are wrong for some values. Always test boundary values and a value from each band. A third problem is comparing text and numbers incorrectly, for example when a score is stored as text. If a formula returns unexpected results, check whether the source cells contain numbers or text, and convert them if needed.
Tips for Readable Nested IF Formulas
Write your conditions in a consistent order, use clear labels, and add a note in a nearby cell explaining the bands. If you must use more than five levels, break the logic into helper columns, so each column handles one step, or switch to IFS or a lookup. Helper columns may look less elegant, but they are much easier to check, and they make errors far easier to find.
Frequently Asked Questions
How many IF functions can you nest in Excel?
Excel allows up to 64 nested IF functions in a single formula, but in practice you should keep the chain much shorter. After four or five levels, the formula becomes hard to read and hard to maintain, so consider IFS, SWITCH, or a lookup table for longer chains.
What is the difference between IF and nested IF?
A basic IF function tests one condition and returns one of two results. A nested IF places another IF function inside the first one, so Excel can test a second, third, or further condition when the earlier tests are false, and return a different result for each case.
Why is my nested IF returning the wrong result?
The most common causes are conditions tested in the wrong order, a missing equals sign in a boundary test, text stored as numbers, or a missing quotation mark around a text result. Check the order first, then test one value from each band, including values that sit exactly on a boundary.
Can you use AND or OR inside a nested IF?
Yes. You can write a test such as IF(AND(B2>=80,C2=”Pass”),”Merit”,…) to require two conditions at once, or use OR when either condition is enough. Combining these functions keeps the formula compact, but test each combination carefully before copying it down a column.
When should I use IFS instead of nested IF?
Use IFS when you have many conditions and each test is simple, because IFS lists each test and result as a pair without nesting. Use a nested IF when you need to support older Excel versions, or when the chain is short and a nested IF is easier for your team to understand.
[…] Excel Nested IF Statements: How to Use Them With Examples […]
[…] Excel Nested IF Statements: How to Use Them With Examples […]
[…] Excel Nested IF Statements: How to Use Them With Examples […]
[…] Excel Nested IF Statements: How to Use Them With Examples […]