Multiple IF Conditions in Excel

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”))))

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 excelNested 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:

Syntax

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

Examples

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.

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

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

This formula returns the result as given below:

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.

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”)))

Excellent: >=70

Good: Between 60 & 69

Average: Between 41 & 59

Bad: <=40

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.

We can make a formula with the logic:

  • If either Q1 or Q2 targets are greater than 70, then the employee gets a 10% bonus,If either of them is greater than 60, then the employee receives a 7% bonus,If either of them is greater than 50, then the employee gets a 5% bonus,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%,””))))

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

Example #4

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

  • If both Q1 and Q2 targets are greater than 70, then the employee gets a 10% bonusif both of them are greater than 60, then the employee receives a 7% bonusif both of them are greater than 50, then the employee gets a 5% bonusif both of them are greater than 40, then the employee receives a 3% bonusElse, 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%,””))))

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

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”))

  • 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:

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

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 testLogical 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.

  • 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’sVLOOKUP 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.

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 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.

  • IF OR in VBAIF 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 moreCOUNTIF in ExcelCOUNTIF 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 moreIFERROR Excel Function – ExamplesIFERROR 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 moreSUMIF Excel FunctionSUMIF 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