Excel IF statement with multiple conditions

The tutorial shows how to create multiple IF statements in Excel with AND as well as OR logic. Also, you will learn how to use IF together with other Excel functions.

In the first part of our Excel IF tutorial, we looked at how to construct a simple IF statement with one condition for text, numbers, dates, blanks and non-blanks. For powerful data analysis, however, you may often need to evaluate multiple conditions at a time. The below formula examples will show you the most effective ways to do this.

How to use IF function with multiple conditions

In essence, there are two types of the IF formula with multiple criteria based on the AND / OR logic. Consequently, in the logical test of your IF formula, you should use one of these functions:

  • AND function - returns TRUE if all the conditions are met; FALSE otherwise.
  • OR function - returns TRUE if any single condition is met; FALSE otherwise.

To better illustrate the point, let's investigate some real-life formulas examples.

Excel IF statement with multiple conditions (AND logic)

The generic formula of Excel IF with two or more conditions is this:

IF(AND(condition1, condition2, …), value_if_true, value_if_false)

Translated into a human language, the formula says: If condition 1 is true AND condition 2 is true, return value_if_true; else return value_if_false.

Suppose you have a table listing the scores of two tests in columns B and C. To pass the final exam, a student must have both scores greater than 50.

For the logical test, you use the following AND statement: AND(B2>50, C2>50)

If both conditions are true, the formula will return "Pass"; if any condition is false - "Fail".

=IF(AND(B2>50, B2>50), "Pass", "Fail")

Easy, isn't it? The screenshot below proves that our Excel IF /AND formula works right: Excel IF statement with multiple AND conditions

In a similar manner, you can use the Excel IF function with multiple text conditions.

For instance, to output "Good" if both B2 and C2 are greater than 50, "Bad" otherwise, the formula is:

=IF(AND(B2="pass", C2="pass"), "Good!", "Bad") Excel IF function with multiple text conditions

Important note! The AND function checks all the conditions, even if the already tested one(s) evaluated to FALSE. Such behavior is a bit unusual since in most of programming languages, subsequent conditions are not tested if any of the previous tests has returned FALSE.

In practice, a seemingly correct IF statement may result in an error because of this specificity. For example, the below formula would return #DIV/0! ("divide by zero" error) if cell A2 is equal to 0:

=IF(AND(A2<>0, (1/A2)>0.5),"Good", "Bad")

The avoid this, you should use a nested IF function:

=IF(A2<>0, IF((1/A2)>0.5, "Good", "Bad"), "Bad")

For more information, please see IF AND formula in Excel.

Excel IF function with multiple conditions (OR logic)

To do one thing if any condition is met, otherwise do something else, use this combination of the IF and OR functions:

IF(OR(condition1, condition2, …), value_if_true, value_if_false)

The difference from the IF / AND formula discussed above is that Excel returns TRUE if any of the specified conditions is true.

So, if in the previous formula, we use OR instead of AND:

=IF(OR(B2>50, B2>50), "Pass", "Fail")

Then anyone who has more than 50 points in either exam will get "Pass" in column D. With such conditions, our students have a better chance to pass the final exam (Yvette being particularly unlucky failing by just 1 point :) Excel IF function with multiple OR conditions

Tip. In case you are creating a multiple IF statement with text and testing a value in one cell with the OR logic (i.e. a cell can be "this" or "that"), then you can build a more compact formula using an array constant.

For example, to mark a sale as "closed" if cell B2 is either "delivered" or "paid", the formula is:

=IF(OR(B2={"delivered", "paid"}), "Closed", "")

More formula examples can be found in Excel IF OR function.

IF with multiple AND & OR statements

If your task requires evaluating several sets of multiple conditions, you will have to utilize both AND & OR functions at a time.

In our sample table, suppose you have the following criteria for checking the exam results:

  • Condition 1: exam1>50 and exam2>50
  • Condition 2: exam1>40 and exam2>60

If either of the conditions is met, the final exam is deemed passed.

At first sight, the formula seems a little tricky, but in fact it is not! You just express each of the above conditions as an AND statement and nest them in the OR function (since it's not necessary to meet both conditions, either will suffice):

OR(AND(B2>50, C2>50), AND(B2>40, C2>60)

Then, use the OR function for the logical test of IF and supply the desired value_if_true and value_if_false values. As the result, you get the following IF formula with multiple AND / OR conditions:

=IF(OR(AND(B2>50, C2>50), AND(B2>40, C2>60), "Pass", "Fail")

The screenshot below indicates that we've done the formula right: IF with multiple AND & OR statements

Naturally, you are not limited to using only two AND/OR functions in your IF formulas. You can use as many of them as your business logic requires, provided that:

  • In Excel 2007 and higher, you have no more than 255 arguments, and the total length of the IF formula does not exceed 8,192 characters.
  • In Excel 2003 and lower, there are no more than 30 arguments, and the total length of your IF formula does not exceed 1,024 characters.

Nested IF statement to check multiple logical tests

If you want to evaluate multiple logical tests within a single formula, then you can nest several functions one into another. Such functions are called nested IF functions. They prove particularly useful when you wish to return different values depending on the logical tests' results.

Here's a typical example: suppose you want to qualify the students' achievements as "Good", "Satisfactory" and "Poor" based on the following scores:

  • Good: 60 or more (>=60)
  • Satisfactory: between 40 and 60 (>40 and <60)
  • Poor: 40 or less (<=40)

Before writing a formula, consider the order of functions you are going to nest. Excel will evaluate the logical tests in the order they appear in the formula. Once a condition evaluates to TRUE, the subsequent conditions are not tested, meaning the formula stops after the first TRUE result.

In our case, the functions are arranged from largest to smallest:

=IF(B2>=60, "Good", IF(B2>40, "Satisfactory", "Poor"))

Naturally, you can nest more functions if needed (up to 64 in modern versions). Nested IF statement in Excel

For more information, please see How to use multiple nested IF statements in Excel.

Excel IF array formula with multiple conditions

Another way to get an Excel IF to test multiple conditions is by using an array formula.

To evaluate conditions with the AND logic, use the asterisk:

IF(condition1) * (condition2) * …, value_if_true, value_if_false)

To test conditions with the OR logic, use the plus sign:

IF(condition1) + (condition2) + …, value_if_true, value_if_false)

To complete an array formula correctly, press the Ctrl + Shift + Enter keys together. In Excel 365 and Excel 2021, this also works as a regular formula due to support for dynamic arrays.

For example, to get "Pass" if both B2 and C2 are greater than 50, the formula is:

=IF((B2>50) * (C2>50), "Pass", "Fail") IF array formula with multiple AND conditions

In my Excel 365, a normal formula works just fine (as you can see in the screenshots above). In Excel 2019 and lower, remember to make it an array formula by using the Ctrl + Shift + Enter shortcut.

To evaluate multiple conditions with the OR logic, the formula is:

=IF((B2>50) + (C2>50), "Pass", "Fail") IF array formula with multiple OR conditions

Using IF together with other functions

This section explains how to use IF in combination with other Excel functions and what benefits this gives to you.

Example 1. If #N/A error in VLOOKUP

When VLOOKUP or other lookup function cannot find something, it returns a #N/A error. To make your tables look nicer, you can return zero, blank, or specific text if #N/A. For this, use this generic formula:

IF(ISNA(VLOOKUP(…)), value_if_na, VLOOKUP(…))

For example:

If #N/A return 0:

If the lookup value in E1 is not found, the formula returns zero.

=IF(ISNA(VLOOKUP(E1, A2:B10, 2,FALSE )), 0, VLOOKUP(E1, A2:B10, 2, FALSE))

If #N/A return blank:

If the lookup value is not found, the formula returns nothing (an empty string).

=IF(ISNA(VLOOKUP(E1, A2:B10, 2,FALSE )), "", VLOOKUP(E1, A2:B10, 2, FALSE))

If #N/A return certain text:

If the lookup value is not found, the formula returns specific text.

=IF(ISNA(VLOOKUP(E1, A2:B10, 2,FALSE )), "Not found", VLOOKUP(E1, A2:B10, 2, FALSE)) If #N/A error in VLOOKUP

For more formula examples, please see VLOOKUP with IF statement in Excel.

Example 2. IF with SUM, AVERAGE, MIN and MAX functions

To sum cell values based on certain criteria, Excel provides the SUMIF and SUMIFS functions.

In some situations, your business logic may require including the SUM function in the logical test of IF. For example, to return different text labels depending on the sum of the values in B2 and C2, the formula is:

=IF(SUM(B2:C2)>130, "Good", IF(SUM(B2:C2)>110, "Satisfactory", "Poor"))

If the sum is greater than 130, the result is "good"; if greater than 110 – "satisfactory', if 110 or lower – "poor". Using the IF function with SUM

In a similar fashion, you can embed the AVERAGE function in the logical test of IF and return different labels based on the average score:

=IF(AVERAGE(B2:C2)>65, "Good", IF(AVERAGE(B2:C2)>55, "Satisfactory", "Poor"))

Assuming the total score is in column D, you can identify the highest and lowest values with the help of the MAX and MIN functions:

=IF(D2=MAX($D$2:$D$10), "Best result", "")

=IF(D2=MAX($D$2:$D$10), "Best result", "")

To have both labels in one column, nest the above functions one into another:

=IF(D2=MAX($D$2:$D$10), "Best result", IF(D2=MIN($D$2:$D$10), "Worst result", "")) Using IF together with the MIN and MAX functions

Likewise, you can use IF together with your custom functions. For example, you can combine it with GetCellColor or GetCellFontColor to return different results based on a cell color.

In addition, Excel provides a number of functions to calculate data based on conditions. For detailed formula examples, please check out the following tutorials:

  • COUNTIF - count cells that meet a condition
  • COUNTIFS - count cells with multiple criteria
  • SUMIF - conditionally sum cells
  • SUMIFS - sum cells with multiple criteria

Example 3. IF with ISNUMBER, ISTEXT and ISBLANK

To identify text, numbers and blank cells, Microsoft Excel provides special functions such as ISTEXT, ISNUMBER and ISBLANK. By placing them in the logical tests of three nested IF statements, you can identify all different data types in one go:

=IF(ISTEXT(A2), "Text", IF(ISNUMBER(A2), "Number", IF(ISBLANK(A2), "Blank", ""))) IF with ISNUMBER, ISTEXT and ISBLANK

Example 4. IF and CONCATENATE

To output the result of IF and some text into one cell, use the CONCATENATE or CONCAT (in Excel 2016 - 365) and IF functions together. For example:

=CONCATENATE("You performed ", IF(B1>100,"fantastic!", IF(B1>50, "well", "poor")))

=CONCAT("You performed ", IF(B1>100,"fantastic!", IF(B1>50, "well", "poor")))

Looking at the screenshot below, you'll hardly need any explanation of what the formula does: Using IF and CONCATENATE

IF ISERROR / ISNA formula in Excel

The modern versions of Excel have special functions to trap errors and replace them with another calculation or predefined value - IFERROR (in Excel 2007 and later) and IFNA (in Excel 2013 and later). In earlier Excel versions, you can use the IF ISERROR and IF ISNA combinations instead.

The difference is that IFERROR and ISERROR handle all possible Excel errors, including #VALUE!, #N/A, #NAME?, #REF!, #NUM!, #DIV/0!, and #NULL!. While IFNA and ISNA specialize solely in #N/A errors.

For example, to replace the "divide by zero" error (#DIV/0!) with your custom text, you can use the following formula:

=IF(ISERROR(A2/B2), "N/A", A2/B2) Using IF together with ISERROR

And that's all I have to say about using the IF function in Excel. I thank you for reading and hope to see you on our blog next week!

Practice workbook for download

Excel IF multiple criteria - examples (.xlsx file)

4538 comments

  1. i am trying with formal but actually it working only till above 5K only as below:

    IF(E2<=500, "Paid", IF(E2=5000,"Above 5k", IF(E2>=10000,"Above 10k", IF(E2>=20000,"Above 20k", IF(E2>=40000,"Above 40k", IF(E2>=60000,"Above 60k", IF(E2>=80000,"Above 80k" ))))))))

    0 Paid
    0 Paid
    8,833.36 Above 5k
    12,965.89 Above 5k
    2,644.26 Less 5k
    88,654.84 Above 5k
    15,801.28 Above 5k
    4,320.72 Less 5k

  2. How to implement below in Excel formula

    Example

    If Mexico than Latin
    If India,china,bhutan,japan then asia
    Else europe

    Other are not included here.

  3. Please can you help me to calculate the number of interlocking stones to be produced?

    6,680kg - Stone dust
    25kg - Cement

    to produce 50 pieces ( 1m2)

    I want it in such a way that whenever I input the quantities of cement and stone dust, it will give me the number to be produced.

  4. I'm not sure if this is possible. I've been struggling with it for a couple of hours:

    I need a conditional formula that is conditional on the value in a single cell. For example
    If F2="Apple" and E3>F3 then G3=1 or 0 if second condition isn't met but,
    If F2="Orange" and E3>1 then G3=1 or 0 if second condition isn't met but,
    If F2="Grape" and E3>F3 then G3=1 or 0 if second condition isn't met but,
    If F2="Banana" and E3>1.5 then G3=1 or 0 if second condition isn't met and etc.

    Typing it out sounds sort of irrational but I feel like there should be a way that I can manipulate the formulas. Any ideas?

    • Hello!
      If I understand your task correctly, try the following formula:

      =IF(OR(AND(F2="Apple",E3>F3),AND(F2="Orange",E3>1),AND(F2="Gape",E3>F3),AND(F2="Banana",E3>1.5)),1,0)

      You can read more details here - IF AND OR formula.

      • I did not see your response as I was typing my own. My apologies. This formula works perfectly! Thank you!

    • I figured out how do do what I mentioned above. For anyone reading this that may find it helpful, in the above example the formula that goes in cell G3 would be:

      =IF(OR(AND(F2="Apple", E3>F3), AND(F2="Orange", E3>1), AND(F2="Grape", E3>F3), AND(F2="Banana", E3>1.5)), 1, 0)

  5. I'm not sure if this is possible. I've been struggling with it for a couple of hours:

    I need a conditional formula that is conditional on the value in a single cell. For example
    if F2=Apple

  6. I am trying to work a formula with the following:

    T1= Week 1 and U1 = 4 calculate D3/4
    T1= Week 2 and U1 = 4 calculate D3/2
    T1= Week 3 and U1 = 4 calculate (D3/4)*3
    T1= Week 4 and U1 = 4 enter D3
    T2= Week 1 and U1 = 5 calculate D3/5
    T2= Week 2 and U1 = 5 calculate (D3/5)*2
    T2= Week 3 and U1 = 5 calculate (D3/5)*3
    T2= Week 4 and U1 = 5 calculate (D3/5)*4
    T2= Week 5 and U1 = 5 enter D3

    Tried the following formula but it doesn't seem to work

    =IF(OR(AND($T$1="Week 1",$U$1="4",D3/4),AND($T$1="week 2",$U$1="4",D3/2),AND($T$1="Week 3",$U$1="4",(D3/4)*3),AND($T$1="Week 1",U1="5",D3/5),AND($T$1="Week 2",$U$1="5",(D3/5)*2),AND($T$1="Week 3",$U$1="5",(D3/5)*3),AND($T$1="Week 4",$U$1="5",(D3/5)*4)),D3)

    Can you help?

    • Hello!
      For the first four conditions, use a nested IF function. It is impossible to combine all conditions in one formula, as they contradict each other. For example, the first and fifth conditions can return TRUE at the same time.

      =IF(AND(T1="Week 1",U1=4),D3/4, IF(AND(T1="Week 2",U1=4),D3/2, IF(AND(T1="Week 3",U1=4),D3/4*3, IF(AND(T1="Week 4",U1=4),D3,""))))

      I hope it’ll be helpful.

      • Thank you - this is helpful!

  7. Hope someone can help me figure this out.
    I have a column "date rented" formatted mm/dd/yyyy.
    What I need to do is the following numeric values returned based on tenant's length of stay:
    If 5 years and 10 years and 5 years and 30 years then 5

    • Hope someone can help me figure this out. I have a column "Birth Date".
      What I need is return the following numeric values based on the Date column
      - If Birth Date 2 years and 5 years and 10 years then 4

  8. Can you please help me to get a suitable formulas for :

    Cell Number : B5

    (B5) Not Exceeding 53846 - (C7*10%)
    (B5) Exceeding 53846 but not exceeding 75000 - (C7*12.5%)
    (B5) Exceeding 75000 - (C7*15%)

    Please ignore my previous message. it was a mistake.

    Thanks

    Samad

  9. Can you please provide me with assistance for a multiple "IF" formula, using the following conditions;

    If the value in cell B27 is between 15 and 17, then the answer = 350
    If the value in cell B27 is between 18 and 19, then the answer = 800
    If the value in cell B27 is between 20 and 24, then the answer = 1350
    If the value in cell B27 is greater than 24, then the answer = 2350
    If the value in cell B27 is less than 15, then the answer = 0

    So far I have come up with the following formula for the first condition:

    =IF(AND(B27>15,B27<18),350,0

    This works, but when I try to add the other conditions I get an error. Can you please show me what I need to do to add the other criteria to this formula correctly.

    • Oops, I meant =IF(AND(B27>14,B27<18),350,0)

      • Hi Alexander,

        Thanks for your reply, it is very much appreciated.

        However, your formula didn't quite work properly. I have made the following adjustment to your formula and this now works fine.

        =IF(B27>24,2350,IF(B27>19,1350,IF(B27>17,800,IF(B27>14,350,0))))

        Thanks again for your assistance.

        Kind regards,
        Collis

  10. Thank you in advance for your help. I am having a problem coming up with a formula to:

    If cell 2 is blank do nothing, if cell 1 is greater than cell 2 do nothing, if cell 1 is less than cell 2 subtract cell 2 from cell 1.

    Any help you can offer would be appreciated.

    • Hi!
      I hope you have studied the recommendations in the tutorial above. It contains answers to your question.
      I’m not sure I got you right since the description you provided is not entirely clear. However, it seems to me that the formula below will work for you:

      =IF(A1 < A2,A1-A2,"")

      • Thank you for responding but your formula got cut off. All I got was =IF(A1.

          • Thank you but my problem is still that if cell A2 is empty I want it to do nothing. As it is now if cell A2 is empty it is counting it as zero and deducting zero from cell A1 and showing the amount. I guess I forgot to point out this formula is being used in cell A3. That probably makes a difference. Sorry about that.

              • Sorry to keep bothering you but I am still getting a calculation if the cell is empty. To be more specific in G13 I am looking for a formula that will do nothing if E13 is empty or if D13 is more than E13. If E13 is less than D13 I want G13 to show D13-E13. The formula I am using is:

                =IF(E13=“”,””,IF(D13>E13,D13–E13,””))

                Everything works except that when E13 is empty G13 is showing D13-E13 which it is counting as zero. In the scenario I want G13 to do nothing at all.

                Again sorry to keep bothering you but I have been working on this for hours. Lol

              • Hi!
                The formula you wrote down doesn't match the formula I gave you. Look carefully.
                The conditions you wrote contradict each other.
                "if D13 is more than E13" - "do nothing"
                "If E13 is less than D13"- "show D13-E13"
                But "if D13 is more than E13" and "If E13 is less than D13" - this is the same.

  11. Dear Sir,

    We need you help regarding the below function. The below function working stock monitoring.
    But SHORTAGE not coming automatically and other all function working.
    I need you intervention in issue.

    =IF(O59>=F59,"RACK FULL",IF(O59>=H59,"Max Level",IF(O59>=G59,"Min Level",IF(O59<=G59,"PLAN PROD",IF(T59<1,"SHORTAGE")))))

  12. Dear Alexander Trifuntov,

    I really appreciate your knowledge and I hope you can help me.
    I have the following case:

    A) 200,000
    B) 100,000
    C) 50,000
    SUM: 350,000

    If the sum is equal to or greater than 350000, then write me 350000*0.2%, if the sum is less than 350000, and A is greater than or equal to 200000, then write me 20000*0.2%, and if A is less than 200000, and the sum is less than 350000, then write me 0.

  13. is it possible to put this in 1 "IF" condition:

    ABHLSV = 849233122
    BCCSS1 = 827221821
    HAMLTN = 861957608
    NIAGAR = 933106071
    RMHLTH = 865288670
    COHPA = 871044031
    MCGILL = 636844772
    AHSOUT = 639741451
    HORZON = 630095514

  14. Hello, need a quick help with the if condition along with concatenate function.
    I have this data as mentioned below in column A. Now, wherever "AA" appears in column A, I want to concatenate the column A with F1 and wherever "XA" appears in column A, I want to concatenate the column A with F2. How could i do this?
    I am pasting the data from column A and also the output required in column B for your reference:
    Coumn A Column B
    AA,FS AA,FS,F1
    AA,FS
    AA,FS
    AA,FS
    XA,GP,FT XA,GP,FT,F2
    XA,GP,FT
    XA,GP,FT
    AA,GP,FS

  15. =IF(O4 > =F4,"RACK FULL",IF(O4 > =H4,"Max Level",IF(O4 > =G4,"Min Level",IF(O4 > =G4,"PLAN PROD",IF(T4 < 1,"SHORTAGE")))))

  16. Hello,

    I`m looking for correct IF formula, would you please help me?

    Column B = M and F letters
    Column C = Numbers (60-90)
    Populate column G to return "Male Achiever" if Gender = M and the score in column C is > 95, "Female Achiever" if Gender = F and the score in column C is > 95, otherwise "None"

  17. I am looking to do an IF: when
    If this person is found
    I need to multiple the number hours worked by a set dollar
    I have multiple people i need to run this for.
    Can you help?
    Thank you

  18. I have a column with age in months and based on the age there are four things that can happen. I need another column that returns one of the four results "" below. I need help with a formula for how to do this. Here are the four criteria I need to incorporate:

    If 5 months and less then "waitlist"
    If 6 months to 30 months then "infant"
    If 31 months to 54 months then "toddler"
    If 55 months or more than "aged out".

    Can you help?

      • Something in this formula is off. It gives the value of "aged out" for everything. I have a column with age in months - that the formula is pointing to. I cannot figure it out for the life of me.

        Thank you for any insight.

        • I figured it out! I didn't need the part of the formula (DATEDIF) because I already had a column with that info. This was so helpful! Thank you

  19. Hi

    I have a data set with 3 columns and 100+ rows;
    Column A = Person, B = Value, C = Percentage

    I need to find a way to return the top 3 persons (Column A), this is based on the highest Value (B) and the highest percentage (C).

    What is the best way to do this??

    Thanks

  20. I am discombobulated. I hope u guys can help.
    I need to count the incentive but it has some certain condition.
    1. You need to see the on/off boarding date.
    2. You need to see the load/unloading date (of the cargo)
    3a. If a new hire joins before the load date, then they would get a 100% and the one who leaves, gets nothing.
    3b. If a new hire joins at the same day, then they would get 40%. The one who leaves, gets 60%.
    3c. If a new hire joins after the load date, but before the unload date, they would get 25%. The one who leaves, gets 75%
    3d. If a new hire joins right on or after the unload date, they get 0%. The one who leaves, gets a 100%.

    :')

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)