Multiple conditioning in excel

Multiple IF Conditions in Excel

The multiple IF conditions in Excel are IF statements contained within another IF statement. They are used to test multiple conditions simultaneously and return distinct values. The additional IF statements can be included in the “value if true” and “value if false” arguments of a standard IF formula.

For example, suppose we have a dataset of students’ scores from B1:B12. We need to grade the students according to their scores. Then, using the IF condition, we can manage the multiple conditions. In this example, we can insert the nested IF formula in cell D1 to assign a grade to a score. We can grade total score as “A,” “B,” “C,” “D,” and “F.” A score would be “F” if it is greater than or equal to 30, “D” if it is greater than 60, and “C” if it is greater than or equal to 70, and “A,” “B” if the score is less than 95. We can insert the formula in D1 with 5 separate IF functions:

=IF(B1>30,”F”,IF(B1>60,”D”,IF(B1>70,”C”,IF(C5>80,”B”,”A”))))

Table of contents
  • Multiple IF Condition in Excel
    • Explanation
    • Examples
      • Example #1
      • Example #2
      • Example #3
      • Example #4
    • Things to Remember
    • Recommended Articles

Explanation

The IF formula is used when we wish to test a condition and return one value if the condition is met and another value if it is not met.

Each subsequent IF formula is incorporated into the “value_if_false” argument of the previous IF. So, the nested IF excelIn Excel, nested if function means using another logical or conditional function with the if function to test multiple conditions. For example, if there are two conditions to be tested, we can use the logical functions AND or OR depending on the situation, or we can use the other conditional functions to test even more ifs inside a single if.read more formula works as follows:

multiple Conditions

Syntax

IF (condition1, result1, IF (condition2, result2, IF (condition3, result3,………..)))

Examples

You can download this Multiple Ifs Excel Template here – Multiple Ifs Excel Template

Example #1

Suppose we wish to find how a student scores in an exam. There are two exam scores of a student, and we define the total score (sum of the two scores) as “Good,” “Average,” and “Bad.” A score would be “Good” if it is greater than or equal to 60, ‘Average’ if it is between 40 and 60, and ‘Bad’ if it is less than or equal to 40.

Let us say the first score is stored in column B, the second in column C.

Multiple ifs Example 1

The following formula tells Excel to return “Good,” “Average,” or “Bad”:

=IF(D2>=60,”Good”,IF(D2>40,”Average”,”Bad”))

Multiple ifs Example 1-1

This formula returns the result as given below:

Multiple ifs Example 1-2

Drag the formula to get results for the rest of the cells.

We can see that one multiple IF function is sufficient in this case as we need to get only 3 results.

Multiple ifs Example 1-3

We can see that one multiple IF function is sufficient in this case as we need to get only 3 results.

Example #2

We want to test one more condition in the above examples: the total score of 70 and above is categorized as “Excellent.”

=IF(D2>=70,”Excellent”,IF(D2>=60,”Good”,IF(D2>40,”Average”,”Bad”)))

Multiple ifs Example 2

This formula returns the result as given below:

Multiple ifs Example 2-1

Excellent: >=70

Good: Between 60 & 69

Average: Between 41 & 59

Bad: <=40

Drag the formula to get results for the rest of the cells.

Multiple ifs Example 2-2

We can add several “IF” conditions if required similarly.

Example #3

Suppose we wish to test a few sets of different conditions. In that case, those conditions can be expressed using logical OR and AND, nesting the functions inside IF statements and then nesting the IF statements into each other.

For instance, if we have two columns containing the number of targets made by an employee in 2 quarters: Q1 and Q2. Then, we wish to calculate the performance bonus of the employee based on a higher target number.

Multiple ifs Example 3

We can make a formula with the logic:

  1. If either Q1 or Q2 targets are greater than 70, then the employee gets a 10% bonus,
  2. If either of them is greater than 60, then the employee receives a 7% bonus,
  3. If either of them is greater than 50, then the employee gets a 5% bonus,
  4. If either is greater than 40, then the employee receives a 3% bonus. Else, no bonus.

So, we first write a few OR statements like (B2>=70,C2>=70), and then nest them into logical tests of IF functions as follows:

=IF(OR(B2>=70,C2>=70),10%,IF(OR(B2>=60,C2>=60),7%, IF(OR(B2>=50,C2>=50),5%, IF(OR(B2>=40,C2>=40),3%,””))))

Multiple ifs Example 3-1

This formula returns the result as given below:

Multiple ifs Example 3-2

Next, drag the formula to get the results of the rest of the cells.

Multiple ifs Example 3-3

Example #4

Now, let us say we want to test one more condition in the above example:

  1. If both Q1 and Q2 targets are greater than 70, then the employee gets a 10% bonus
  2. if both of them are greater than 60, then the employee receives a 7% bonus
  3. if both of them are greater than 50, then the employee gets a 5% bonus
  4. if both of them are greater than 40, then the employee receives a 3% bonus
  5. Else, no bonus.

So, we first write a few AND statements like (B2>=70,C2>=70), and then nest them: tests of IF functions as follows:

=IF(AND(B2>=70,C2>=70),10%,IF(AND(B2>=60,C2>=60),7%, IF(AND(B2>=50,C2>=50),5%, IF(AND(B2>=40,C2>=40),3%,””))))

Multiple ifs Example 4

This formula returns the result as given below:

Multiple ifs Example 4-1

Next, drag the formula to get results for the rest of the cells.

Drag Example 4-2

Things to Remember

  • The multiple IF function evaluates the logical tests in the order they appear in a formula. So, for example, as soon as one condition evaluates to be “True,” the following conditions are not tested.
    • For instance, if we consider the second example discussed above, the multiple IF condition in Excel evaluates the first logical test (D2>=70) and returns “Excellent” because the condition is “True” in the below formula:

=IF(D2>=70,”Excellent”,IF(D2>=60,,”Good”,IF(D2>40,”Average”,”Bad”))

Now, if we reverse the order of IF functions in Excel as follows:

=IF(D2>40,”Average”,IF(D2>=60,,”Good”,IF(D2>=70,”Excellent”,”Bad”))

In this case, the formula tests the first condition. Since 85 is greater than or equal to 70, a result of this condition is also “True,” so the formula would return “Average” instead of “Excellent” without testing the following conditions.

Correct Order

Correct Order

Incorrect Order

InCorrect Order

Note: Changing the order of the IF function in Excel would change the result.

  • Evaluate the formula logic– To see the step-by-step evaluation of multiple IF conditions, we can use the ‘Evaluate Formula’ feature in excel on the “Formula” tab in the “Formula Auditing” group. Clicking the “Evaluate” button will show all the steps in the evaluation process.
  • For instance, in the second example, the evaluation of the first logical testA logical test in Excel results in an analytical output, either true or false. The equals to operator, “=,” is the most commonly used logical test.read more of multiple IF formulas will go as D2>=70; 85>=70; True; Excellent.

Evaluate

  • Balancing the parentheses: If the parentheses do not match in terms of number and order, then the multiple IF formula would not work.
    • If we have more than one set of parentheses, the parentheses pairs are shaded in different colors so that the opening parentheses match the closing ones.
    • Also, on closing the parenthesis, the matching pair is highlighted.
  • Numbers and Text should be treated differently: The text should always be enclosed in double quotes in the multiple IF formula.
  • Multiple IF’s can often become troublesome: Managing many true and false conditions and closing brackets in one statement becomes difficult. Therefore, it is always good to use other tools like IF function or VLOOKUP in case Multiple IF’sSometimes while working with data, when we match the data to the reference Vlookup, it finds the first value and does not look for the next value. However, for a second result, to use Vlookup with multiple criteria, we need to use other functions with it.read more are difficult to maintain in Excel.

Recommended Articles

This article is a guide to Multiple IF Conditions in Excel. We discuss using multiple IF conditions, practical examples, and a downloadable Excel template. You may also learn more about Excel from the following articles: –

  • IF OR in VBAIF OR is not a single statement; it is a pair of logical functions used together in VBA when we have more than one criteria to check, and when we use the if statement, we receive the true result if either of the criteria is met.read more
  • COUNTIF in ExcelThe COUNTIF function in Excel counts the number of cells within a range based on pre-defined criteria. It is used to count cells that include dates, numbers, or text. For example, COUNTIF(A1:A10,”Trump”) will count the number of cells within the range A1:A10 that contain the text “Trump”
    read more
  • IFERROR Excel Function – ExamplesThe IFERROR function in Excel checks a formula (or a cell) for errors and returns a specified value in place of the error.read more
  • SUMIF Excel FunctionThe SUMIF Excel function calculates the sum of a range of cells based on given criteria. The criteria can include dates, numbers, and text. For example, the formula “=SUMIF(B1:B5, “<=12”)” adds the values in the cell range B1:B5, which are less than or equal to 12.
    read more

The IF function allows you to make a logical comparison between a value and what you expect by testing for a condition and returning a result if True or False.

  • =IF(Something is True, then do something, otherwise do something else)

So an IF statement can have two results. The first result is if your comparison is True, the second if your comparison is False.

IF statements are incredibly robust, and form the basis of many spreadsheet models, but they are also the root cause of many spreadsheet issues. Ideally, an IF statement should apply to minimal conditions, such as Male/Female, Yes/No/Maybe, to name a few, but sometimes you might need to evaluate more complex scenarios that require nesting* more than 3 IF functions together.

* “Nesting” refers to the practice of joining multiple functions together in one formula.

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it’s false.

Syntax

IF(logical_test, value_if_true, [value_if_false])

For example:

  • =IF(A2>B2,»Over Budget»,»OK»)

  • =IF(A2=B2,B4-A4,»»)

Argument name

Description

logical_test   

(required)

The condition you want to test.

value_if_true   

(required)

The value that you want returned if the result of logical_test is TRUE.

value_if_false   

(optional)

The value that you want returned if the result of logical_test is FALSE.

Remarks

While Excel will allow you to nest up to 64 different IF functions, it’s not at all advisable to do so. Why?

  • Multiple IF statements require a great deal of thought to build correctly and make sure that their logic can calculate correctly through each condition all the way to the end. If you don’t nest your formula 100% accurately, then it might work 75% of the time, but return unexpected results 25% of the time. Unfortunately, the odds of you catching the 25% are slim.

  • Multiple IF statements can become incredibly difficult to maintain, especially when you come back some time later and try to figure out what you, or worse someone else, was trying to do.

If you find yourself with an IF statement that just seems to keep growing with no end in sight, it’s time to put down the mouse and rethink your strategy.

Let’s look at how to properly create a complex nested IF statement using multiple IFs, and when to recognize that it’s time to use another tool in your Excel arsenal.

Examples

Following is an example of a relatively standard nested IF statement to convert student test scores to their letter grade equivalent.

Complex nested IF statement - Formula in E2 is =IF(B2>97,"A+",IF(B2>93,"A",IF(B2>89,"A-",IF(B2>87,"B+",IF(B2>83,"B",IF(B2>79,"B-",IF(B2>77,"C+",IF(B2>73,"C",IF(B2>69,"C-",IF(B2>57,"D+",IF(B2>53,"D",IF(B2>49,"D-","F"))))))))))))

  • =IF(D2>89,»A»,IF(D2>79,»B»,IF(D2>69,»C»,IF(D2>59,»D»,»F»))))

    This complex nested IF statement follows a straightforward logic:

  1. If the Test Score (in cell D2) is greater than 89, then the student gets an A

  2. If the Test Score is greater than 79, then the student gets a B

  3. If the Test Score is greater than 69, then the student gets a C

  4. If the Test Score is greater than 59, then the student gets a D

  5. Otherwise the student gets an F

This particular example is relatively safe because it’s not likely that the correlation between test scores and letter grades will change, so it won’t require much maintenance. But here’s a thought – what if you need to segment the grades between A+, A and A- (and so on)? Now your four condition IF statement needs to be rewritten to have 12 conditions! Here’s what your formula would look like now:

  • =IF(B2>97,»A+»,IF(B2>93,»A»,IF(B2>89,»A-«,IF(B2>87,»B+»,IF(B2>83,»B»,IF(B2>79,»B-«, IF(B2>77,»C+»,IF(B2>73,»C»,IF(B2>69,»C-«,IF(B2>57,»D+»,IF(B2>53,»D»,IF(B2>49,»D-«,»F»))))))))))))

It’s still functionally accurate and will work as expected, but it takes a long time to write and longer to test to make sure it does what you want. Another glaring issue is that you’ve had to enter the scores and equivalent letter grades by hand. What are the odds that you’ll accidentally have a typo? Now imagine trying to do this 64 times with more complex conditions! Sure, it’s possible, but do you really want to subject yourself to this kind of effort and probable errors that will be really hard to spot?

Tip: Every function in Excel requires an opening and closing parenthesis (). Excel will try to help you figure out what goes where by coloring different parts of your formula when you’re editing it. For instance, if you were to edit the above formula, as you move the cursor past each of the ending parentheses “)”, its corresponding opening parenthesis will turn the same color. This can be especially useful in complex nested formulas when you’re trying to figure out if you have enough matching parentheses.

Additional examples

Following is a very common example of calculating Sales Commission based on levels of Revenue achievement.

Formula in cell D9 is IF(C9>15000,20%,IF(C9>12500,17.5%,IF(C9>10000,15%,IF(C9>7500,12.5%,IF(C9>5000,10%,0)))))

  • =IF(C9>15000,20%,IF(C9>12500,17.5%,IF(C9>10000,15%,IF(C9>7500,12.5%,IF(C9>5000,10%,0)))))

This formula says IF(C9 is Greater Than 15,000 then return 20%, IF(C9 is Greater Than 12,500 then return 17.5%, and so on…

While it’s remarkably similar to the earlier Grades example, this formula is a great example of how difficult it can be to maintain large IF statements – what would you need to do if your organization decided to add new compensation levels and possibly even change the existing dollar or percentage values? You’d have a lot of work on your hands!

Tip: You can insert line breaks in the formula bar to make long formulas easier to read. Just press ALT+ENTER before the text you want to wrap to a new line.

Here is an example of the commission scenario with the logic out of order:

Formula in D9 is out of order as =IF(C9>5000,10%,IF(C9>7500,12.5%,IF(C9>10000,15%,IF(C9>12500,17.5%,IF(C9>15000,20%,0)))))

Can you see what’s wrong? Compare the order of the Revenue comparisons to the previous example. Which way is this one going? That’s right, it’s going from bottom up ($5,000 to $15,000), not the other way around. But why should that be such a big deal? It’s a big deal because the formula can’t pass the first evaluation for any value over $5,000. Let’s say you’ve got $12,500 in revenue – the IF statement will return 10% because it is greater than $5,000, and it will stop there. This can be incredibly problematic because in a lot of situations these types of errors go unnoticed until they’ve had a negative impact. So knowing that there are some serious pitfalls with complex nested IF statements, what can you do? In most cases, you can use the VLOOKUP function instead of building a complex formula with the IF function. Using VLOOKUP, you first need to create a reference table:

Formula in cell D2 is =VLOOKUP(C2,C5:D17,2,TRUE)

  • =VLOOKUP(C2,C5:D17,2,TRUE)

This formula says to look for the value in C2 in the range C5:C17. If the value is found, then return the corresponding value from the same row in column D.

Formula in cell C9 is =VLOOKUP(B9,B2:C6,2,TRUE)

  • =VLOOKUP(B9,B2:C6,2,TRUE)

Similarly, this formula looks for the value in cell B9 in the range B2:B22. If the value is found, then return the corresponding value from the same row in column C.

Note: Both of these VLOOKUPs use the TRUE argument at the end of the formulas, meaning we want them to look for an approxiate match. In other words, it will match the exact values in the lookup table, as well as any values that fall between them. In this case the lookup tables need to be sorted in Ascending order, from smallest to largest.

VLOOKUP is covered in much more detail here, but this is sure a lot simpler than a 12-level, complex nested IF statement! There are other less obvious benefits as well:

  • VLOOKUP reference tables are right out in the open and easy to see.

  • Table values can be easily updated and you never have to touch the formula if your conditions change.

  • If you don’t want people to see or interfere with your reference table, just put it on another worksheet.

Did you know?

There is now an IFS function that can replace multiple, nested IF statements with a single function. So instead of our initial grades example, which has 4 nested IF functions:

  • =IF(D2>89,»A»,IF(D2>79,»B»,IF(D2>69,»C»,IF(D2>59,»D»,»F»))))

It can be made much simpler with a single IFS function:

  • =IFS(D2>89,»A»,D2>79,»B»,D2>69,»C»,D2>59,»D»,TRUE,»F»)

The IFS function is great because you don’t need to worry about all of those IF statements and parentheses.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Related Topics

Video: Advanced IF functions

IFS function (Microsoft 365, Excel 2016 and later)

The COUNTIF function will count values based on a single criteria

The COUNTIFS function will count values based on multiple criteria

The SUMIF function will sum values based on a single criteria

The SUMIFS function will sum values based on multiple criteria

AND function

OR function

VLOOKUP function

Overview of formulas in Excel

How to avoid broken formulas

Detect errors in formulas

Logical functions

Excel functions (alphabetical)

Excel functions (by category)

To perform complicated and powerful data analysis, you need to test various conditions at a single point in time. The data analysis might require logical tests also within these multiple conditions.

For this, you need to perform Excel if statement with multiple conditions or ranges that include various If functions in a single formula.

Those who use Excel daily are well versed with Excel If statement as it is one of the most-used formula. Here you can check various Excel If or statement, Nested If, AND function, Excel IF statements, and how to use them. We have also provided a VIDEO TUTORIAL for different If Statements.

There are various If statements available in Excel. You have to know which of the Excel If you will work at what condition. Here you can check multiple conditions where you can use Excel If statement.

1) Excel If Statement

Excel-If-functions

If you want to test a condition to get two outcomes then you can use this Excel If statement.

=If(Marks>=40, “Pass”)

2) Nested If Statement

Let’s take an example that met the below-mentioned condition

  • If the score is between 0 to 60, then Grade F
  • If the score is between 61 to 70, then Grade D
  • If the score is between 71 to 80, then Grade C
  • If the score is between 81 to 90, then Grade B
  • If the score is between 91 to 100, then Grade A

Then to test the condition the syntax of the formula becomes,

=If(B5<60, “F”,If(B5<71, “D”, If(B5<81,”C”,If(B5<91,”B”,”A”)

Nested-If-statement

3) Excel If with Logical Test

There are 2 different types of conditions AND and OR. You can use the IF statement in excel between two values in both these conditions to perform the logical test.

AND Function: If you are performing the logical test based on AND function, then excel will give you TRUE as an outcome in every condition else it will return false.

OR Function: If you are using OR condition for the logical test, then excel will give you an outcome as TRUE if any of the situations match else it returns false.

For this, multiple testing is to be done using AND and OR function, you should gain expertise in using either or both of these with IF statement. Here we have used if the function with 3 conditions.

How to apply IF & AND function in Excel

  • To perform this multiple if and statements in excel, we will take the data set for the student’s marks that contain fields such as English and Math’s Marks.
  • The score of the English subject is stored in the D column whereas the Maths score is stored in column E.
  • Let say a student passes the class if his or her score in English is greater than or equal to 20 and he or she scores more than 60 in Maths.
  • To create a report in matters of seconds, if formula combined with AND can suffice.
  • Type =IF( Excel will display the logical hint just below the cell F2. The parameters of this function are logical_test, value_if_true, value_if_false.
  • The first parameter contains the condition to be matched. You can use multiple If and AND conditions combined in this logical test.
  • In the second parameter, type the value that you want Excel to display if the condition is true. Similarly, in the third parameter type the value that will be displayed if your condition is false.Excel-if-statement-multiple-condition-range
  • Apply If & And formula, you will get =IF(AND(D2>=20,E2>=60),”Pass”,”Fail”).

If formula

  • Add Pass/Fail column in the current table.Excel-If-conditions
  • After you have applied this formula, you will find the result in the column.
  • Copy the formula from cell F2 and paste in all other cells from F3 to F13.Excel-If-And-statement

How to use If with Or function in Excel

To use If and Or statement excel, you need to apply a similar formula as you have applied for If & And with the only difference is that if any of the condition is true then it will show you True.

To apply the formula, you have to follow the above process. The formula is =IF((OR(D2>=20, E2>=60)), “Pass”, “Fail”). If the score is equal or greater than 20 for column D or the second score is equal or greater than 60 then the person is the pass.

How to Use If with And & Or function

If you want to test data based on several multiple conditions then you have to apply both And & Or functions at a single point in time. For example,

Situation 1: If column D>=20 and column E>=60

Situation 2: If column D>=15 and column E>=60

If any of the situations met, then the candidate is passed, else failed. The formula is

=IF(OR(AND(D2>=20, E2>=60), AND(D2>=20, E2>=60)), “Pass”, “Fail”).

4) Excel If Statement with other functions

Above we have learned how to use excel if statement multiple conditions range with And/Or functions. Now we will be going to learn Excel If Statement with other excel functions.

  • Excel If with Sum, Average, Min, and Max functions

Let’s take an example where we want to calculate the performance of any student with Poor, Satisfactory, and Good.

If the data set has a predefined structure that will not allow any of the modifications. Then you can add values with this If formula:

=If((A2+B2)>=50, “Good”, If((A2+B2)=>30, “Satisfactory”, “Poor”))

Using the Sum function,

=If(Sum(A2:B2)>=120, “Good”, If(Sum(A2:B2)>=100, “Satisfactory”, “Poor”))

Using the Average function,

=If(Average(A2:B2)>=40, “Good”, If(Average(A2:B2)>=25, “Satisfactory”, “Poor”))

Using Max/Min,

If you want to find out the highest scores, using the Max function. You can also find the lowest scores using the Min function.

=If(C2=Max($C$2:$C$10), “Best result”, “ “)

You can also find the lowest scores using the Min function.

=If(C2=Min($C$2:$C$10), “Worst result”, “ “)

If we combine both these formulas together, then we get

=If(C2=Max($C$2:$C$10), “Best result”, If(C2=Min($C$2:$C$10), “Worst result”, “ “))

You can also call it as nested if functions with other excel functions. To get a result, you can use these if functions with various different functions that are used in excel.

So there are four different ways and types of excel if statements, that you can use according to the situation or condition. Start using it today.

So this is all about Excel If statement multiple conditions ranges, you can also check how to add bullets in excel in our next post.

I hope you found this tutorial useful

You may also like the following Excel tutorials:

  • Multiple If Statements in Excel
  • Excel Logical test
  • How to Compare Two Columns in Excel (using VLOOKUP & IF)
  • Using IF Function with Dates in Excel (Easy Examples)

The IF function is one of the most commonly used in Excel. The function can test a single condition as well as perform multiple complex logic tests. We can thus control the execution of Excel tasks using the IF function.

This is important since it enables us to perform actions depending on whether they meet certain conditions defined by the IF formula. We can also add data to cells using the function if other cells meet any of the conditions defined in the IF formula.

To add multiple conditions to an IF formula, we simply add nested IF functions.

In this article, you will learn the basics of the IF function and how to come up with an array of IF formulas. You will also learn the nested IF’s function.

Let’s get started!

1. Basic IF formula that tests a single condition

A single IF statement tests whether a condition is met and returns a value if TRUE and another value if FALSE.

IF (logical test, ‘value_if_true’, ‘value_if_false’)

In the example below, let us test whether the price is less than or equal to 2000. If the condition is true return cheap, otherwise return expensive!

Go to Cell C2 and type ‘=IF(B2<=2000,»CHEAP», «EXPENSIVE»)’

The if formula above records or posts the String Good whenever the single condition B2<=2000.

2. IF formula with multiple conditions (Nested IF Functions.

If you have complex data or want to perform powerful data analysis, you might need to test multiple conditions at a time. You might need to perform a logical test across multiple conditions.

In such cases, you have to use an IF statement with multiple conditions/ranges in a single formula. These multiple IF conditions are normally called nested IF Functions.  The function is used if want more than 3 different results. 

The general syntax for IF function with multiple conditions is

=IF (condition one is true, do something, IF (condition two is true, do something, IF (conditions three is true, do something, else do something)))

Commas are used to separate conditions and IF functions in the IF formula. The «)» is used to close all IFs at the End of the formula while the » (» opens all IF functions. The number of «(» should be equal to that of «)».

In our above example, we can include multiple conditions in the IF formula as follows

=IF(B2<=2000,»CHEAP»,IF(B2<=6000,»AFFORDABLE»,IF(B2<=10000,»EXPENSIVE»,»LUXURIOUS»)))

Press Enter to get the results and use the AutoFill feature to copy the formula to the rest of the cells.

3. IF formula with logical test

You can use an IF statement with AND and OR conditions to perform a logical test. IF your formula has AND function, the logical test returns TRUE if all the conditions are met; otherwise, it will return FALSE. While the OR Function returns TRUE if any of the conditions is met; otherwise it returns FALSE.

3.1 IF with AND Function

In the example below, a student is deemed to pass the exam if he/she has a score of 42 in Maths and 50 in English.

With this information, we can write the condition as follows;

AND (C14>=42, D14>=50)

To know whether the student passed or failed the exam. You can use the IF statement.

= IF(AND (C14>=42, D14>=50),”PASS”,”FAIL”)

Press enter and use the AutoFill feature to copy the formula to the rest of the cells.

3.2 IF with OR Function

The IF with OR Function works the same way as the AND function we have seen above. The only difference is that, if one of the conditions is TRUE then the result will be TRUE.

Follow the above process to apply the OR Function.

In cell E14, type = IF(OR (C14>=42, D14>=50),”PASS”,”FAIL”)

Press enter to get the results.

3. IF with ISNUMBER and ISTEXT Functions

You can use ISNUMBER and ISTEXT formula to find whether the cells have text value, number, or blank.

=IF(ISTEXT(A1), «Text», IF(ISNUMBER(A1), «Number», IF(ISBLANK(A1), «Blank», «»)))

You can only apply AND & OR functions at a time if your task requires you to evaluate several sets of conditions. For example, if you are checking exam results using these criteria:

Condition 1: exam1>50 and exam2>50

Condition 2: exam1>40 and exam2>60

In this case, the exam is deemed passed if either of the conditions is passed.

Although the formula may seem tricky, you only need to express each condition as an AND statement and nest them in the OR function. That is because meeting all the conditions is not necessary, but either statement will serve the purpose. Therefore, the general formula will be:

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

You can now use the OR function to test the logic of IF and supply the desired value_if_true and value_if_false values. In the end, the final IF formula with multiple AND & OR statements will turn into:

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

5. Using the Array Formula

An Array formula can also help to get an Excel IF to test multiple conditions. For example, to evaluate the AND logical condition, you can use the asterisk:

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

While to test conditions using OR logic, you will apply the plus sign:

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

Finally, you can complete the Array formula by pressing Ctrl + Shift + Enter buttons together. The trick can also work as a regular formula in Excel 365 and Excel 2021 since it supports dynamic arrays.

Example: We can get “Pass” if cells B2 and C2 are greater than 50 by applying the formulas;

=IF((B2>50) * (C2>50), «Pass», «Fail») for AND logic

…, and

=IF((B2>50) + (C2>50), «Pass», «Fail») for OR logic.

6. IF With Other Excel Functions

Other Excel functions that can give the IF formula for multiple conditions include

6.1 IF#N/A Error in VLOOKUP Function

The VLOOKUP or any other lookup function returns a N/A error if it cannot find something. Therefore, you can return zero, blank, or text if #N/A to make your table neat. Here, you will need the following generic formula:

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

Example 1. If the lookup value in a cell (E1) is not found, the formula returns 0 as shown below;

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

Example 2: If the lookup value is not found, the formula returns blank as shown below;

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

Example 3: If the lookup value is not available, the formula returns a specific text as shown below;

=IF(ISNA(VLOOKUP(E1, A2:B10, 2,FALSE )), «Not found», VLOOKUP(E1, A2:B10, 2, FALSE))

6.2 IF With SUM, AVERAGE, MIN, and MAX Functions

Excel has the SUMIF and SUMIFS functions that you can use, to sum up values in cells using certain criteria. You can use the SUM function to test the IF logic of your business. For instance, you can apply this formula to determine the text labels based on the sum of cells B2 and C2 values;

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

From the formula, the return text label is “Good” if the sum of the two cells is greater than 130. If the sum is greater than 110, the return text is “Satisfactory”, while if the sum is 110 or below, the return text is “Poor”.

You can still embed the AVERAGE function similarly to test the IF logic and return a different text label based on the average score of the two cells. In this case, the generic formula will be;

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

If the sum of cells B2 and C2 is indicated in cell D2, you can use the MAX and MIN functions to identify the highest and lowest values through the formulas;

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

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

Lastly, you can nest the two functions into one another to have both text labels in one column to get the formula;

=IF(D2=MAX($D$2:$D$10), «Best result», IF(D2=MIN($D$2:$D$10), «Worst result», «»))

6.3 IF with CONCATENATE Function

You can also use the CONCATENATE and IF functions to output the result of IF and some text into one cell. Here, you can use the formula;

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

From the formula, the student will get a «fantastic» result if the score in cell B1 is greater than 100. On the other hand, the result will be «well» if the score in cell B1 is greater than 50.

6.4 IF with ISERROR and ISNA Functions

These functions can only work in modern Excel versions where they trap and replace errors with another predefined value. For instance, the IFERROR function works in Excel 2007 and later, while the IFNA function works in Excel 2013 and later. When using earlier Excel versions, you will need the combinations of IF ISERROR and IF ISNA. So, what is the difference between these applications?

The answer is simple: IFERROR and ISERROR functions can handle all the possible errors resulting from Excel calculations, including VALUE, N/A, NAME, REF, NUM, DIV/0, and NULL errors. Contrary, IFNA, and ISNA handle only N/A errors.

Example: If you want to replace the #DIV/0 (divide by zero error) with a predefined text or value, you can use the formula;

=IF(ISERROR(A2/B2), «N/A», A2/B2), where;

A2 represents the value in cell A2

B2 represents the value in cell B2.

A2/B2 represents the results attained after dividing A2 by B2.

If the value in cell B2 is 0, the formula will return a N/A text.

I hope you found this tutorial useful.

I received a lot of questions on how to use IF function with 3 conditions, so I’ve decided to write an article on this topic.

The IF examples described in this article assume that you have a basic understanding of how the IF function works. All examples from this article work in Excel for Microsoft 365 or Excel 2021, 2019, 2016, 2013, 2010, and 2007.

IF is one of the most used Excel functions. In case you are unfamiliar with the IF function, then I strongly recommend reading my article on Excel IF function first. It’s a step-by-step guide, and it includes a lot of useful examples. It also shows the basics of writing an Excel IF statement with multiple conditions, but it’s not as detailed as this guide. Make sure you also download the exercise file.

As a data analyst, you need to be able to evaluate multiple conditions at the same time and perform an action or display certain values when the logical tests are TRUE. This means that you will need to learn how to write more complex formulas, which sooner or later will include multiple IF statements in Excel, nested one inside the other.

Let’s take a look at how to write a simple IF function with 3 logical tests.

The first example uses an IF statement with three OR conditions. We will use an IF formula which sets the Finance division name if the department is Accounting, Financial Reporting, or Planning & Budgeting.

The IF statement from cell E31 is:
=IF(OR(D31="Accounting", D31="Financial Reporting", D31="Planning & Budgeting"), "Finance", "Other")

IF function with 3 conditions

This IF formula works by checking three OR conditions:

  • Is the data from the cell D31 equal to Accounting? In our case, the answer is no, and the formula continues and evaluates the second condition.
  • Is the text from the cell D31 equal to Financial Reporting? The answer is still no, and the formula continues and evaluates the third condition.
  • Is the text from the cell D31 equal to Planning & Reporting? The answer is yes, our IF function returns TRUE, and displays the word Finance in cell E31.

Next, we focus our attention on an example that uses an IF statement with three AND conditions.

Our table shows exam scores for three exams. If the student received a score of at least 70 for all three exams, then we will return Pass. Otherwise, we will display Fail.

The IF statement from cell H53 is:
=IF(AND(E53>=70, F53>=70, G53>=70), "Pass", "Fail")

IF function with 3 logical tests

This IF formula works by checking all three AND conditions:

  • Is the score for Exam 1 higher than or equal to 70? In our case, the answer is yes, and the formula continues and evaluates the second condition.
  • Is the score for Exam 2 higher than or equal to 70? Well, yes it is. Now the formula moves to the third condition.
  • Is the score for Exam 3 higher than or equal to 70? Yes, it is. Since all three conditions are met, the IF statement is TRUE and returns the word Pass in cell H53.

Excel IF statement with multiple conditions

The final section of this article is focused on how to write an Excel IF statement with multiple conditions, and it includes two examples:

  • multiple nested IF statements (also known as nested IFS)
  • formula with a mix of AND, OR, and NOT conditions

How many IF statements can you nest in Excel? The answer is 64, but I’ve never seen a formula that uses that many. Also, I’m sure that there are far better alternatives to using such a complicated formula.

Multiple nested IF statements

In this example, I have calculated the grade of the students based on their scores using a formula with 4 nested IF functions.

=IF(E107<60, "F", IF(E107<70, "D", IF(E107<80, "C", IF(E107<90, "B" ,"A"))))

Note: In this case, the order of the conditions influences the result of your formula. When your conditions overlap, Excel will return the [value_if_true] argument from the first IF statement that is TRUE and ignores the rest of the values. If you want your formula to work properly, always pay attention to the logical flow and the order of your nested IF functions.

If you have to write an IF statement with 3 outcomes, then you only need to use one nested IF function. The first IF statement will handle the first outcome, while the second one will return the second and the third possible outcomes.

4 nested IF statements

Note: If you have Office 365 installed, then you can also use the new IFS function. You can read more about IFS on Microsoft’s website.

Multiple IF statements in Excel with AND, OR, and NOT conditions

I have saved the best for last. This example is the most advanced from this article, as it involves an IF statement with several other logical functions.

In the exercise file, I have included a list of orders. Each row includes the order date, the order value, the product category, and the free shipping flag. We want to flag orders as eligible if the following cumulative logical conditions are met:

  • the order was placed during 2020
  • the order includes products from only two categories: PC or Laptop
  • the order was not flagged as Free shipping

The formula I’ve used for cell H80 is shown below:

=IF(AND(D80>=DATE(2020,1,1), D80<=DATE(2020,12,31), OR(F80="PC", F80="Laptop"), NOT(G80="Yes")), "Eligible", "Not eligible")

IF statement with AND, OR, and NOT functions

Here’s how this works:

  1. AND makes sure that all the logical conditions need to be met to flag the order as Eligible. If any of them is FALSE, then our entire IF statement will return the [value_if_false] argument.
  2. D80>=DATE(2020,1,1) and D80<=DATE(2020,12,31) check if the order was placed between January 1st and December 31st, 2020.
  3. OR is used to check whether the product category is PC or Laptop.
  4. Finally, NOT is used to check if the Free shipping flag is different from Yes.

I’ve also added a video that shows how to nest IF functions in case you are still having difficulties understanding how a nested IF formula works.

And there you have it. I hope that after reading this guide, you have a much better understanding of using IF function with 3 logical tests (or any number actually). While it may seem intimidating at first, I guarantee that if you write an IF formula with multiple criteria daily, your productivity will eventually skyrocket.

This is why, if you have any questions on how to use IF function with 3 conditions, please leave a comment below and I will do my best to help you out. I reply to every comment or email that I receive.

Понравилась статья? Поделить с друзьями:
  • Multiple columns to one column in excel
  • Multiple choice quiz in word
  • Multiple choice questions in word
  • Multipage1 pages в excel
  • Multipage vba excel примеры