Nested IF Functions in Excel

The simplest Nested IF Function is using one IF Function inside another. When you have more than a few choices, nesting more IF Functions can quickly get complicated and, quite frankly, there are better ways to make decisions with Excel. Having said that, I have a simple method to account for the different choices that can arise with nested IF Functions.

Two Conditions – Binary Outcome

Two Conditions Binary OutcomeThe IF Function evaluates a logical test to either TRUE or FALSE. A binary outcome. One condition requires only one IF Function.

With two conditions that both evaluate to TRUE/FALSE you must consider all possible outcomes.

This chart shows there are four different outcomes for Condition 1 and 2. I’ve added a third column to determine what action to take for each outcome.

One Nested IF Function

In this example three actions are required, which means one nested IF Function, so the Action column has the following formula:

=IF(Cond_2=TRUE,”Action 1″,IF(Cond_1=TRUE,”Action 2″,”Action 3″))

Which translates to: if condition 2 is TRUE then do action 1, or if condition 2 is  FALSE and condition 1 is TRUE then do action 2, or if condition 2 is FALSE and condition 1 is FALSE then do action 3.

How Many Actions are Required?

Having two conditions with binary outcomes doesn’t mean there will automatically be three actions for these four possible outcomes. The chart above is designed for you to determine how many actions are required, and then construct the IF statement logic.

Two Nested IF Functions

There could be four different actions needed, which would require two nested IF Functions. Assuming each of the four conditions above has a different outcome, and labeling each Action 1 through 4 from top to bottom, then the following formula will work:

=IF(Cond_1+Cond_2=2,”Action 1″,IF(Cond_1+Cond_2=0,”Action 4″,IF(Cond_1=TRUE,”Action 2″,”Action 3″)))

Which takes advantage of the fact that TRUE + TRUE = 2, FALSE + FALSE = 0, and either combination of TRUE + FALSE = 1.

Three Conditions – Binary Outcome

Three Conditions Binary OutcomeI rarely do more than two nested IF functions because they get complicated. Taking into account the binary nature each outcome, if there are N conditions, then there are 2N possible outcomes that must be accounted for with the formula logic.

I always put together a binary outcome chart when dealing with three conditions. Even if I don’t use nested IF Functions for a sloution, all the outcomes must be considered.

I simply add a column for what action needs to be taken and look to see where the commonality lies for a starting point, then try and compose something to fit.

Excel 2003 can nest up to 7 IF Functions, and Excel 2007 and 2010 both allow 64 nested IF Functions. How anybody could do that many Nested IF’s is beyond me.

If you’re trying to nest more IF Functions than I’ve shown here, I wish you Good Luck.

Related Posts Plugin for WordPress, Blogger...

22 thoughts on “Nested IF Functions in Excel

  1. Eric

    Once you get into more than two conditions, it may pay to look at your desired outcomes and group them. Then treat each condition as a bit in a decision byte… Condition 1 = TRUE and Condition 2 = FALSE and Condition 3 = True => 101 base 2 or 5. Then use a SELECT CASE statement in a macro, or the CHOOSE statement in a cell, to come up with your desired outcome. So the cells formula would be something along the lines of =CHOOSE(EvaluatedConditions, Outcome1, Outcome2, Outcome3, etc).

    1. Gregory

      I agree with you Eric. When I mentioned “better ways to make decisions” my first thought was to create a custom function using the SELECT CASE statement as you mentioned. And my second thought was the CHOOSE Function, although I don’t think I’ve ever used that one in a spreadsheet.

      As far as treating each condition as a bit in a decision byte, I get your meaning, but that’s slightly over my head. Thanks for the comment.

    1. Gregory

      In this post I’m sticking with TRUE or FALSE outcomes for the IF Function to keep it simple. You can certainly use OR or AND Functions inside an IF Function, but then you run into an entirely different set of possible outcomes, which is a good topic for another article. Thanks for the comment.

  2. Greg N

    I’m a student at a university and we are working on excel and i am having a bit of difficulty we are given a 3×6 table example shown below and are required to “Create a formula/function as either … Failed, Passed, or achieved Honors. The cell should simply state: “Failed”, “Passed”, “Honors” – depending on their scores.”
    student test1 test2 test3
    Chelsea 60 65 80

    If any of the three scores falls below 60, the person fails the Law Exam. If the scores are all 80 or above, then the person is in the Honors ranking. If the scores are 60 or better but any one of the scores is below 80, they passed, but are not in the Honors ranking.

    how do i do this?

    1. Eric

      Assumes the Student “Chelsea” is in A2, and her grades for test1-3 are in B2:D2. For your “grade” cell (B5?), put in the following formula:


      What this does is first check that any of her scores is less than 60. If it is, then she failed. Then, in the “FALSE” section of the first If statement, you check for the other two conditions. That second If statement checks to see if the minimum of her scores is greater than or equal to 80. If it is, then the other two scores are at least as good so she’s in the Honors section. And if she didn’t fail or isn’t in honors then she passed.



      1. Eric

        Whoops! That didn’t copy right. Here’s the correct function:


        1. Eric

          OK, it must be the greater than and equal sign…

          =If(Min(B2:D2)<60, "Failed",If(Min(B2:D2) GTE 80,"Honors","Passed"))

          Put a gt and an = sign in for GTE


    2. Gregory

      There are two conditions that require functions. Then put them into a Nested IF function and your done. Assume all the scores are in cells B2, C2, and D2. For the first condition, put a heading in cell E1 of Min<60. Then use the formula:


      This will give a TRUE answer if all scores are above 79, which is the same thing as saying 80 or greater.

      Now for these two conditions you have only three outcomes, because if Min<60 is TRUE, then Honors? can't be TRUE, it's FALSE. The remaining two outcomes are if Min<60 is FALSE and Honors? is TRUE then they get Honors. And finally if Min<60 if FALSE and Honors? is FALSE they passed.

      Put the label Grade in cell G1 and in cell G2 the formula:


      Putting everything together in one formula:


      I hope that was clear.

  3. ccd

    What about this formula ?


    How to make it simple and works ?

    It has more than 64 nest…


    1. Gregory

      I bow down to the brain-power that created this massive formula. If there’s more than three or four nested IF statements required, I resort to VBA code.

      1. ccd

        LOL… Come on… please help me out how to make an alternatives for this formula… Or maybe there is a way to modify the “64 nest” rule on the excel ?

        Thanks again

        1. Gregory

          When I copy the formula and put it into a spreadsheet Excel says it has an error. Perhaps you could send me the spreadsheet with this working formula and I can take a look to see if it can be simplified. Email to: [email protected]

          1. ccd


            thats the original formula….

          2. Gregory

            I had to remove every instance of “1-2” and “3-4” because Excel wouldn’t accept the quotes, and then I got a warning that there were more than 64 levels of nesting. So I’m stuck.

  4. Kaushik Ray

    CCD : Your gigantic formula is nothing but finding the contents of a two way array. Where the values in L3 cell takes values from cell D3 to D35. And K3 cell takes fixed values 1-2, 3-4, & 5.
    Simply use MATCH function to find the row (Rx) and column (Cx) of the array your target value is in. Then use ” =CELL(“contents”,INDIRECT(ADDRESS(Rx, Cx)))

    Yes, it is that simple 🙂

    1. Gregory

      Your point is taken. However “simple” is a relative term. This post is written for people who struggle with more than one IF function. Given that premise, throwing in the MATCH, CELL, INDIRECT, and ADDRESS functions are difficult enough by themselves, yet together they are incomprehensible to my target audience.

  5. yaser

    can u help me
    how i can write more than 22 conditions in excel as below was give me error


    1. Gregory

      Instead of using a large number of IF statements, the VLOOKUP function would be much, much simpler if you can put your list in a table. The first column of the table holds the lookup data, “7/1” “7/1/1” etc. and the second column holds the answer you want to provide. I’ll send you an example worksheet with your data to show the details.

      Hope this helps.

Comments are closed.