How to Create a NESTED IF Function in Excel

How to Create a NESTED IF Function in Excel

I remember the exact spreadsheet where I first needed a nested IF. I was building a grading sheet for a training course, and a simple “Pass or Fail” IF statement wasn’t enough — I needed A, B, C, D, and F grades based on score ranges. My first instinct was to write five separate helper columns, which quickly became a mess. Then I learned how to nest IF functions inside each other, and suddenly one formula handled the entire grading logic. In this article, I’ll show you exactly how to do the same thing.

What Is a Nested IF Function?

A nested IF function is simply an IF function placed inside another IF function, allowing you to test multiple conditions in sequence rather than just one true/false condition. A basic IF function can only return one of two results — true or false. A nested IF extends that logic to handle three, four, five, or more possible outcomes, all within a single formula.

The basic structure looks like this:

=IF(condition1, result1, IF(condition2, result2, IF(condition3, result3, result4)))

Excel evaluates each condition in order, and as soon as one is true, it returns the corresponding result and stops checking further.

Why Use Nested IF Functions?

Required Data Before You Start

To build a nested IF, you need:

  1. A cell containing the value you want to evaluate (like a test score, sales figure, or age).
  2. A clear set of conditions and thresholds you want to test against.
  3. A defined result for each possible outcome, including a final “catch-all” result for anything that doesn’t match earlier conditions.

I always recommend writing out your logic in plain English first — for example, “If score is 90 or above, grade is A. Otherwise, if 80 or above, grade is B…” — before trying to translate it into formula syntax.

Step-by-Step: How to Build a Nested IF Function

Step 1: Identify Your Conditions in Order

List your conditions from highest to lowest (or lowest to highest, depending on your logic), since Excel checks them sequentially.

Step 2: Start with the First IF

Click the cell where you want the result to appear and type:

=IF(A2>=90,"A",

Step 3: Nest the Next IF Inside the “False” Argument

Instead of typing a final result yet, start another IF function where the false result would go:

=IF(A2>=90,"A",IF(A2>=80,"B",

Step 4: Continue Nesting for Each Condition

Keep adding IF functions for each additional threshold:

=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C",IF(A2>=60,"D","F"))))

Step 5: Close All Parentheses

Each IF function opens a parenthesis, so make sure you close exactly as many as you opened. Excel will show an error if they don’t match.

Step 6: Press Enter and Test

Confirm the formula, then test it against several different values to make sure each condition triggers the correct result.

Practical Example

Let’s build a full grading formula for a score in cell A2:

=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C",IF(A2>=60,"D","F"))))

Here’s another common example — a tiered sales commission structure based on total sales in cell B2:

=IF(B2>=100000,"15%",IF(B2>=50000,"10%",IF(B2>=25000,"5%","0%")))

This assigns a 15% commission for sales over $100,000, 10% for $50,000–$99,999, 5% for $25,000–$49,999, and 0% below that.

Modern Alternative: IFS Function

If you’re using Excel 2019, Excel 365, or newer, there’s a cleaner alternative called IFS, which avoids nested parentheses entirely:

=IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",A2>=60,"D",TRUE,"F")

This does the exact same thing as the nested IF example above but is often easier to read and edit, especially with many conditions. I recommend using IFS when it’s available, and reserving nested IF for compatibility with older Excel versions or when combining logic with other functions.

Common Mistakes to Avoid

  1. Mismatched parentheses – every nested IF adds one more closing parenthesis at the end. Miscounting these is the most common error.
  2. Wrong condition order – if you check A2>=60 before A2>=90, every high score will incorrectly return the lower-tier result, since Excel stops at the first TRUE condition it finds.
  3. Exceeding Excel’s nesting limit – older Excel versions only support up to 7 nested IFs; if you need more, consider IFS, LOOKUP, or a helper table instead.
  4. Forgetting the final “else” value – always include a catch-all result for values that don’t match any condition, or the formula may return FALSE unexpectedly.
  5. Overcomplicating logic that AND/OR could simplify – sometimes combining conditions with AND or OR inside a single IF is cleaner than deeply nesting multiple IFs.

Troubleshooting Tips

Real-World Use Cases

Best Practices

Final Thoughts

Nested IF functions are a gateway skill in Excel — once you understand how to chain conditions together, you unlock the ability to build much more sophisticated decision-making formulas. Start simple, test each condition as you build it, and don’t be afraid to switch to IFS or a lookup table if your logic starts getting too deep. With a little practice, what once felt like an intimidating wall of parentheses will become second nature.

Exit mobile version