The tutorial explains how to use multiple IF in Excel and provides a couple of nested If formula examples for most common tasks.
If someone asks you what Excel function you use most often, what would your answer be? In most cases, it's the Excel IF function. A regular If formula that tests a single condition is very straightforward and easy to write. But what if your data requires more elaborate logical tests with multiple conditions? In this case, you can include several IF functions in one formula, and these multiple If statements are called Excel Nested IF. The biggest advantage of the nested If statement is that it allows you to check more than one condition and return different values depending on the results of those checks, all in a single formula.
Microsoft Excel has limits to the levels of nested IFs. In Excel 2003 and lower, up to 7 levels were allowed. In Excel 2007 and higher, you can nest up to 64 IF functions in one formula.
Further on in this tutorial, you will find a couple of Excel nested If examples along with a detailed explanation of their syntax and logic.
Example 1. Classic nested IF formula
Here's a typical example of Excel If with multiple conditions. Supposing you have a list of students in column A and their exam scores in column B, and you want to classify the scores with the following conditions:
- Excellent: Over 249
- Good: between 249 and 200, inclusive
- Satisfactory: between 199 and 150, inclusive
- Poor: Under 150
And now, let's write a nested IF function based on the above criteria. It's considered a good practice to begin with the most important condition and keep your functions as simple as possible. Our Excel nested IF formula goes as follows:
=IF(B2>249, "Excellent", IF(B2>=200, "Good", IF(B2>150, "Satisfactory", "Poor")))
And works exactly as it should:
Understanding Excel nested IF logic
I've heard some people say that Excel multiple If is driving them crazy :) Try looking at it at a different angle:
What the formula actually tells Excel to do is to evaluate the logical_test of the first IF function and, if the condition is met, return the value supplied in the value_if_true argument. If the condition of the 1st If function is not met, then test the 2nd If statement, and so on.
IF(check if B2>=200, if true - return "Good", or else
IF(check if B2>150, if true - return "Satisfactory", if false -
return "Poor")))
If you need a nested IF formula with wildcard characters (partial match), check out this example: If cell contains, then return different values.
Example 2. Multiple If with arithmetic calculations
Here's another typical task: the unit price varies depending on the specified quantity, and your goal is to write a formula that calculates the total price for any amount of items input in a specific cell. In other words, your formula needs to check multiple conditions and perform different calculations depending on what amount range the specified quantity falls in:
Unit Quantity | Price per unit |
1 to 10 | $20 |
11 to 19 | $18 |
20 to 49 | $16 |
50 to 100 | $13 |
Over 101 | $12 |
This task can also be accomplished by using multiple IF functions. The logic is the same as in the above example, the only difference is that you multiply the specified quantity by the value returned by nested IFs (i.e. the corresponding price per unit).
Assuming the user enters the quantity in cell B8, the formula is as follows:
=B8*IF(B8>=101, 12, IF(B8>=50, 13, IF(B8>=20, 16, IF( B8>=11, 18, IF(B8>=1, 20, "")))))
And the result will look something similar to this:
As you understand, this example demonstrates only the general approach, and you can easily customize this nested If function depending on your particular task.
For example, instead of "hard-coding" the prices in the formula, you can reference the cells containing those values (cells B2 to B6). This will enable your users to edit the source data without having to update the formula:
=B8*IF(B8>=101,B6, IF(B8>=50, B5, IF(B8>=20, B4, IF( B8>=11, B3, IF(B8>=1, B2, "")))))
Or, you may want to include an additional IF function(s) that fixes an upper, lower or both bounds of the amount range. When the quantity is outside the range, the formula will display an "out of the range" message. For example:
=IF(OR(B8>200,B8<1), "Qty. out of range", B8*IF(B8>=101,12, IF(B8>=50, 13, IF(B8>=20, 16, IF( B8>=11, 18, IF(B8>=1, 20, ""))))))
The nested IF formulas described above work in all versions of Excel. In Excel 365 and Excel 2021, you can also use the IFS function for the same purpose.
Advanced Excel users that are familiar with array formulas, can use this formula that basically does the same thing as the nested IF function discussed above. Though the array formula is far more difficult to comprehend, let along to write, it has one indisputable advantage - you specify the range of cells containing your conditions rather than referencing each condition individually. This makes the formula more flexible, and if your users happen to change any of the existing conditions or add a new one, you will only have to update a single range reference in the formula.
Excel nested IF - tips and tricks
As you have just seen, there is no rocket science in using multiple IF in Excel. The following tips will help you improve your nested IF formulas and prevent common mistakes.
Nested IF limits
In Excel 2007 - Excel 365, you can nest up to 64 IF functions. In older versions of Excel 2003 and lower, up to 7 nested IF functions can be used. However, the fact that you can nest a lot of IFs in one formula doesn't mean you should. Please keep in mind that each additional level makes your formula more difficult to understand and troubleshoot. If your formula has too many nested levels, you may want to optimize it by using one of these alternatives.
The order of nested IF functions matters
The Excel nested IF function evaluates the logical tests in the order they appear in the formula, and as soon as one of the conditions evaluates to TRUE, the subsequent conditions are not tested. In other words, the formula stops after the first TRUE result.
Let's see how it works in practice. With B2 equal to 274, the nested IF formula below evaluates the first logical test (B2>249), and returns "Excellent" because this logical test is TRUE:
=IF(B2>249, "Excellent", IF(B2>=200, "Good", IF(B2>150, "Satisfactory", "Poor")))
Now, let's reverse the order of IF functions:
=IF(B2>150, "Satisfactory", IF(B2>200, "Good", IF(B2>249, "Excellent", "Poor")))
The formula tests the first condition, and because 274 is greater than 150, the result of this logical test is also TRUE. Consequently, the formula returns "Satisfactory" without testing other conditions.
You see, changing the order of IF functions changes the result:
Evaluate the formula logic
To watch the logical flow of your nested IF formula step-by-step, use the Evaluate Formula feature located on the Formula tab, in the Formula Auditing group. The underlined expression is the part currently under evaluation, and clicking the Evaluate button will show you all the steps in the evaluation process.
For example, the evaluation of the first logical test of the nested IF formula shown in the screenshot below will go as follows: B2>249; 274>249; TRUE; Excellent.
Balance the parenthesis of nested IF functions
One of the main challenges with nested IFs in Excel is matching parenthesis pairs. If the parentheses do not match, your formula won't work. Luckily, Microsoft Excel provides a couple of features that can help you to balance the parentheses when editing a formula:
- If you have more than one set of parentheses, the parenthesis pairs are shaded in different colors so that the opening parenthesis matches the closing one.
- When you close a parenthesis, Excel briefly highlights the matching pair. The same bolding, or "flickering", effect is produced when you move through the formula by using the arrow keys.
For more information, please see Match parenthesis pairs in Excel formulas.
Treat text and numbers differently
When building logical tests of your nested IF formulas, remember that text and numbers should be treated differently - always enclose text values in double quotes, but never put quotes around numbers:
Right: =IF(B2>249, "Excellent",…)
Wrong: =IF(B2>"249", "Excellent",…)
The logical test of the second formula will return FALSE even if the value in B2 is greater than 249. Why? Because 249 is a number and "249" is a numeric string, which are two different things.
Add spaces or line breaks to make nested IFs easier to read
When building a formula with multiple nested IF levels, you can make the formula's logic clearer by separating different IF functions with spaces or line breaks. Excel doesn't care about extra spacing in a formula, so you may not worry about mangling it.
To move a certain part of the formula to the next line, just click where you want to insert a line break, and press Alt + Enter. Then, expand the formula bar as much as needed and you will see that your nested IF formula has become much easier to understand.
Alternatives to nested IF in Excel
To get around the limit of seven nested IF functions in Excel 2003 and older versions and to make your formulas more compact and fast, consider using the following alternatives to nested Excel IF functions.
- To test multiple conditions and return different values based on the results of those tests, you can use the CHOOSE function instead of nested IFs.
- Build a reference table and a use VLOOKUP with approximate match as shown in this example: VLOOKUP instead of nested IF in Excel.
- Use IF with logical functions OR / AND, as demonstrated in the these examples.
- Use an array formula like shown in this example.
- Combine multiple IF statements by using the CONCATENATE function or the concatenate operator (&). A formula example can be found here.
- For experienced Excel users, the best alternative to using multiple nested IF functions might be creating a custom worksheet function using VBA.
This is how you use an If formula in Excel with multiple conditions. I thank you for reading and hope to see you on our blog next week.
Practice workbook for download
Nested If Excel statements (.xlsx file)
650 comments
Your website makes my work so easy. Thank you and your team for the work you guys do. :-)
Hi Alexander,
Thank you for your response. For some reason both times I posted the first formula when it appears on the site it doesn't show the full formula.
I will try one more time to show you which two formulas I am trying to combine.
=IF(F6>=450,"£450.00",IF( AND (F6 250), F6 ,"£250.00")) - I know this shouldn't have spaces, but when I send it as is, it shows with parts missing :S
=IF(F6="N/A","£250.00")
Hi! I have just given you a formula. If it is not what you wanted, give me an example of the source data and a detailed description of the result you want.
Hello,
How do I combine these two formulas? I have tried nesting, AND and OR functions, but nothing seems to work.
=IF(F6>=450,"£450.00",IF(AND(F6250),F6,"£250.00"))
=IF(F6="N/A","£250.00")
F6 is either a number or N/A. If the number is below £250.00 or N/A the outcome should be the same - =IF(OR(F6<=250,F6="N/A"),"£250.00")
Each formula above works independently, I just can't seem to include all the components I want in one formula.
Many thanks,
Ayesha
Hello Ayesha!
If I understand your task correctly, the following formula should work for you:
=IF(F6>=450,"£450.00",IF(OR(F6<=250,F6="N/A"),"£250.00"))
All the necessary information is in the article above.
I am trying to create a formula that sums the totals from multiple IFs.
For example:
Sum of:
If A1>200,1,0
+
If B1>20,2,0
+
If CI is between 4 and 6,1,0
+
If D1=1,1,0
How would I create a formula for this?
Hi Jule!
If I understand your task correctly, just summarize a few IF formulas. For example:
=IF(A1>200,1,0)+IF(B1>20,2,0)
how to using if statement with 3 condition in one cell
Hi! If you didn't find the answer to your question in this article above, then try reading here: Excel IF statement with multiple conditions.
Hlw sir, i have also the some issue in excel formula, below mentioned formula doesn't work , how can i solve it please find the solution.
=IF(AL347>24999,"1",IF(AI347>24999,"1",IF(AF347>24999,"1",IF(AC347>24999,"1",IF(Z347>24999,"1",IF(W347>24999,"1",IF(T347>24999,"1",IF(Q347>24999,"1",IF(N347>24999,"1",IF(K347>24999,"1",IF(H347>24999,"1",IF(E347>24999,"1","0"))))))))))))
Hi! The formula returns no error. But since I don't know what result you want and what data you're using, I can't verify that it works. Explain the problem in more detail. Maybe you can solve the problem in other ways, which are described in this article: Excel Nested IF statements - examples, best practices and alternatives.
EXAMPLE 2: Total shown as $1,300 – looks like a problem!
I am baffled by your total for 100 units. I get $1,505 as the total, as follows:
Cell A2, 10 units X $20 = $200
Cell a3, 9 units x $18 = $162
Cell A4, 30 units x $16 = $480
Cell A5, 51 units x $13 = $663
Total $1,505
Please let me know what I am missing. I am using this example as a guide for a formula in my project, and the result is off. Thanks.
Hello!
Non-Progressive Calculation is used in this example. In non-progressive pricing, all items are offered the same price, and that price is determined by the total sales amount. Or, the same commission rate is paid on all sales, but the commission rate is determined by the total amount of sales during a pay period.
You are using a completely different method of calculation - Progressive Calculation. Progressive commissions are paid on sales up to a certain level. A second rate applies to all sales above the threshold in the same pay period.
However, the Progressive Calculation method is not usually used in the determination of the sales price.
For your calculation, try this formula:
=IF(B8<=10,B8*20,IF(B8<=19, (10*20)+((B8-10)*18),IF(B8<=49, (10*20)+(9*18)+((B8-19)*16), IF(B8<=100, (10*20)+(9*18)+(30*16)+((B8-49)*13), (10*20)+(9*18)+(30*16)+(51*13)+((B8-100)*12)))))
I am trying to build an overtime calculator that differentiates firstly between level of employee, and then type of overtime given.
Variables are:
Manager Junior staff
Overtime rates are 10.00, 20.00 and 40.00 per hour for junior staff, and 20, 40 and 80 per hour for managers.
I can build a formula
=IF([Level]="Junior",(IF([@Rate]=1,"10.00",IF([@Rate]=2,"20.00",IF([@Rate]=4,"80.00"))))) which works, or
=IF([Level]="Manager",(IF([@Rate]=1,"10.00",IF([@Rate]=2,"40.00",IF([@Rate]=4,"80.00")))))
Both of these work.
Is there any way of combining the two formulas into one?
Hi! Please re-check the article above since it covers your case. You can use the second formula as a FALSE argument to the first formula. For example:
=IF([Level]="Junior",(IF([@Rate]=1,"10.00",IF([@Rate]=2,"20.00",IF([@Rate]=4,"80.00")))), IF([Level]="Manager",(IF([@Rate]=1,"10.00",IF([@Rate]=2,"40.00",IF([@Rate]=4,"80.00"))))))
Unfortunately I can't check this formula as it contains unique references to your data which I don't have.
Dear.
Im trying to get my formula to give me the status when the progress of my exercise is at a certain point,therefore it needs to look up in a table
M N N P
Status range Status Days Range 2
-99900% Achterstand -5 Negatieve dagen 3
-15% Vertraging 0 0-5 4
-5% Op schema 5 5-10 5
10% Vooruitlopend 10 10 + 6
At which point the assingment is so if its 15% behind on schedule it has to say vertraging and so on.
I am able to get the function when its done so when its 100%= done but then further down the road im getting lost with my if function.
M2 is the status column
I2= is the progression %
H2 is the deadline
And j2 is datum finished
Are you able to help me, because im keep getting an error notification
Hi! If I understand your task correctly, you can find the progression % in column I and extract the corresponding status from column M using the INDEX MATCH formula. Here is an example from your data:
=INDEX(M2:M5,MATCH(A1,I2:I5,0))
You can find the examples and detailed instructions here: INDEX & MATCH in Excel - better alternative to VLOOKUP.
I hope it’ll be helpful. If this is not what you wanted, please describe the problem in more detail.
Hello Sir,
I have a case and I'm not sure how to plot it or if it is possible, can I have multiple "true" statement? like using & sign?
Something like this, if row 1 is let's say "Above10M" and row 2 is "1st offense", then it will indicate the corresponding amount base on the table provided.
Thank you!
Hello! You can combine several true statements into a single condition using the AND function. Please take a look at this article: IF AND formula in Excel. For example:
=IF(AND(A1="Above10M",B1="1st offense"),C1,"")
Hi there, I am trying to do multiple if functions and as far as I can tell, I'm doing it exactly the way I'm supposed to, but I am not getting the proper results. I don't understand what could be going wrong. The formula is: =IF(I4<500, "NEW",IF(I4<3000,"LIGHT USE",IF(I4<5000,"MEDIUM USE",IF(I47500,"HEAVY USE"))))) but I keep getting the result "HEAVY USE" when the number in I4 is 6. When I change the value in I4, I still get results that don't make any sense. Any help would be appreciated, thank you.
Hello sir please solve this problem.
This example
A1
A2
B2
b3
A4
A5
B6
Same data a1 a3 a2 how to combined data
Sir this different data
Please formula provide
Hi! Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Hi! This formula returns NEW if the value 6 is written in cell I4. If the results of the formula do not suit you, please specify exactly what the results are.
=IF(I4<500,"NEW", IF(I4<3000,"LIGHT USE", IF(I4<5000,"MEDIUM USE", IF(I4<7500,"HEAVY USE"))))
Maybe this article will be helpful: Excel Nested IF statements - examples, best practices and alternatives.
Hello- looking for some help on a if situation
I have an invoice sheet with qty, unit price, net price and total price- i need to multiply qty x unit price unless i enter a price in the net cell also- if i do enter a net price then the qty x net=total price and overrides the unit price cell
I was just using =product(B10,E10) to get qty x unit price- so then i tried- =PRODUCT(B10,E10)*IF(F10="",E10,F10) but this multiplies my total by 10x
B10 is qty
E10 is unit price
F10 is net price
G10 is total price
thanks for any help!
Hello! If I understand your task correctly, the following formula should work for you:
=B10*IF(C10=0,D10,C10)
You can use the IF function to select one of two values based on a condition.
Also, if one of the values is zero, you can select the maximum value using the MAX function.
=B10*MAX(C10:D10)
I hope my advice will help you solve your task.
ty- yes that worked-- ty for the help!