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
Hi Alexander,
Please help me with my following problem.
Cell A2 = 300
B2 = 100
C2 = 500
=IF(A2>B2, A2,B2, IF A2>C2, A2,C2, IF C2>B2, C2,B2)))
The true result will only show the first and the second IF.
Thank you in advance.
Hi!
Based on your description, it is hard to completely understand your task. I don't know what result you want to get. However, I’ll try to guess and offer you the following formula:
=IF(A2>B2,A2,IF(A2>C2,A2,IF(C2>B2,C2,B2)))
Please re-check the article above since it covers your task.
Hi Alexander,
Thank you for the reply. Sorry if I didn't explain the problem well, but you got I what I mean. :)
I tried your formula, however, it only shows that C2 is greater than A2 if B2 is greater than A2. But if B2 is lower that A2, then the answer in the formula is A2 is greater than C2 & B2 which should be C2 is greater than A2 of B2.
Sorry again to bother you but hopefully you can help me with this coz I'm not really good in excel.
Thank you so much!
Hi!
I just corrected the syntax errors in your formula. But I still don't understand what result you want to get. All detailed instructions are in the article above. Or describe in detail the desired result.
Hello I have been stuck on this IF statement for three days now and I keep getting invalid or the pound sign, as well as just the equation I'm inputting to still be there with nothing being done. This one is kind of weird to do, for me: I have to make a nest statement for when I can go to the beach the set up is below. I can only go on Friday, the weather has to be nice and I have to have at least $500. That's the only numeric number but I set it up different ways so many times that I've lost sight of what and how to use the and, can't... =IF(A4<=Friday?, "Yes", IF(A4=,Bad Weather, "No", IF(A4<=$500, "Can't Go"))) A4 is the first cell with Friday in it. Can you tell me what I'm doing wrong? I've watched a couple of youtube vids, and articles but the formulas I try yield the same result: Nothing. Please and thank you for your time.
Friday with an drop down arrow
Friday
Anyday
Sunny and warm
Sunny and warm
Nasty
$500
Hi!
Try to use these recommendations: IF AND in Excel: nested formula, multiple statements.
Hello
I cannot figure out how to fix this IF AND NESTED formula. Please help.
=IF(AND(R2>=19.01, R2=21.01, R2<=23, 70, IF(R2<=23.01, 75, " " )))
Hello again.
There was a copy and paste error in my above question. This is the actual formula that I need help with.
=IF(AND(R2>=19.01, R2=21.01, R2<=23, 70, IF(R2<23.01, 75, "")))
Hi!
I can suggest the following formula -
=IF(AND(R2>=19.01,R2=21.01,R2<=23),70,IF(R2<=23.01,75," "))
For more information, please visit: IF AND in Excel: nested formula, multiple statements, and more.
Hi,
Can you help me with this calculation?
I want to calculate the commission (3%,5%,7% etc) based on the total sales in location i16
=IF(i162000=4000,"i16"/100*5,IF(i16>4000=6000,"i16"/100*7)))
Thanks in advance
Hi!
See Example 2 in the article above. This should solve your task.
Hi so this is my current formula
=IF(OR([@[FULL NAME]]="Player 1",[@[FULL NAME]]="Player 2",[@[FULL NAME]]="Player 3",[@[FULL NAME]]="Player 4",[@[FULL NAME]]="Player 5",[@[FULL NAME]]="Player 6", [@[FULL NAME]]="Player 7", [@[FULL NAME]]="Player 8"),"DEF")
I'm wanting to add two other IF OR onto the formula, so if player 9, player 10, player 11 then itll be MID and then for players 12, 13, 14 itll be 'ATT'.
Does anyone know how I could add these on?
Thanks in advance!
Hello!
Extract digits from text using the RIGHT function. Convert them to a number, as described in this guide.
Use a nested IF function to get the result you want.
=IF(--RIGHT(A1,2)>11,"ATT", IF(--RIGHT(A1,2)>8,"MID","DEF"))
Good morning - I am looking for a simplified formula to calculate all of the possible outcomes between 4 categories (East, Midwest, South, and West) and their 3 potential ratings (Low, Medium, High). The current formula - which has accounted for all possible outcomes - has produced 81 levels of nesting (3 x 3 x 3 x 3 = 81), which obviously is too large and cannot be entered. I was wondering if using IFS instead of nested IFs might work? Any suggestions would be tremendously appreciated - thanks!
Hello!
Create a table where categories are written in rows, and ratings are written in columns. Write down all possible options in the table. Then choose the desired option using two-way lookup.
Look for the example formulas here: Excel INDEX MATCH MATCH and other formulas for two-way lookup.
I hope it’ll be helpful.
Hi,
What can be the formula for this?
Since I have 140k line items, how can I group the Order No. based on the Items?
Let's say classification is not available and I want to group the order no. with multiple types of goods as "Mixed Items".
Order No. Item Classification
1 Fish Mixed Items
1 Veggies Mixed Items
1 Fruits Mixed Items
1 Rice Mixed Items
2 Fish Seafoods Only
2 Fish Seafoods Only
2 Fish Seafoods Only
3 Bread Breads Only
3 Bread Breads Only
Thanks in advance!
Hello!
If I understand your task correctly, try the following formula:
=IF(COUNTA(UNIQUE(FILTER($B$1:$B$100,$A$1:$A$100=A1)))=1,"Mixed items","")
or
=IF(IFERROR(ROWS(UNIQUE(FILTER(B1:B100,$A$1:$A$100=A1))), 0)=1,"Mixed items","")
For more information, please visit: Count unique values with criteria.
I have a column of cells with drop-down options of "Complete", "In Progress", "Not Started", and "Backlog." J6 - J25 specifically.
I have a cell that I am attempting to display the overall progress as a percentage (located at H3).
How do I get a selection of "Complete" to contribute to the percentage as a 100% value, the "In Progress" to contribute to the percentage as a 50% value and all others 0.
For example: J6-8 says, "Complete" "Complete" "Complete"... then H3 will say "100%"
or "Complete", "Not Started" will have H3 showing "50%"
Hi!
Your description of the problem and the example do not match, but the formula could be something like this -
=IF(SUM(--(J6:J8="Complete"))=3,100%,IF(SUM(--(J6:J8="In progress"))=3,50%,""))
About using double dash (--) with boolean values learn more in example 3 in the article - SUMPRODUCT and SUMIFS in Excel. I hope my advice will help you solve your task.
Hi
=IF($G60,$G$4,)&" "&IF($H60,$H$4,)&" "&IF($I60,$I$4,)
G6, H6, I6 = Sales
G4, H4, I4 = Place
Is there any other formula which I can use in place of above formula.
Thanks
Hi!
I don't quite understand what you want to do with this formula.
Pay attention to the correct use of the IF function.
Hi Alex
I have one column (E) where i have the percentage calculated.
Then i have a Target Points Colums (B) with numbers 1-5
now i need to set a condition in COlumn F, where if the average is 100% and above i need to add 1 to the value in column B
100%-110% plus 1 90%-100% minus 1
110%-120% plus 2 80%-90% minus 2
120%-130% plus 3 70%-80% minus 3
130%-140% plus 4 60%-70% minus 4
140%-150% plus 5 50%-60& minus 5
Thanks
A
Hi!
For a single condition, use the normal IF function:
=IF(E1>100%,B1+1,B1)
Hello, please help with any formula suggestions for what I'm trying to do -
For each dollar of new income (as shown in cell D13) between $140 and $220, calculate an abatement of .20cents per dollar, and deduct this from current income (found in D7)....
Then for each dollar of new income (D13) above $220, calculate an abatement of .50cents per dollar, and also deduct this from current income (found in D7).
My version of excel is older; can't use SUMIFS.
(sorry to hijack this thread, can't find where to start a new comment)
Hello!
To calculate interval values, use the MIN function and MAX function.
=MAX(D13-220,0)*0.5+MIN(MAX(D13-140,0),80)*0.2+MIN(D13,140)
Hope this is what you need.
Would like some advice about a nested IF formula. The formula I have written is: =IF(L2>0,L2,IF(K2>0,K2,IF(J2>0,J2,IF(I2>0,I2,G2))))
with the intention that the latest filled column from I to L should be copied over to a new column and if there's nothing in I-L then column G should be copied instead. The formula works if column L is filled in and SOMETIMES if there's only column G to copy but not for any other scenarios.
Example:
G= 7
I = 9
J= 11
K = Blank
L = Blank
M with formula should show 11
I can't work out what I've done wrong!
Hello!
Use the INDEX+MATCH functions to find the last non-empty cell in a range. The following tutorial should help: How to use INDEX and MATCH in Excel.
Please try the following formula -
=INDEX(I1:L1,,MATCH(1E+20,I1:L1,1))
=IFERROR(INDEX(I1:L1,,MATCH(1E+20,I1:L1,1)),G1)
I hope I answered your question.
Yes!!! It worked. Thank you. :)
Hi,
I want to sort company revenue with the following conditions:
$250M
How do I turn this into a nested IF formula? Or do I use another type of formula?
Sorry the conditions didn't load up completely. The conditions are:
$250M
Sorry, just ignore this
On the second thought, can you please evaluate if this formula is correct? Thank you!
IF(Z3 < 100,000.00, "250,000,000.00, " > 250M))))))))))
Hi!
If you have a problem with formulas, I recommend reading this guide: Excel formulas not working, not updating, not calculating: fixes & solutions.
If you fix errors in your formula:
=IF(Z3 < 100000,250000000," > 250M")
Thank you for linking the guide. Bless you!
Hi!
If you want to show values by condition, use the FILTER function or the Excel Filter tool.
If this is not what you wanted, please describe the problem in more detail.
Please support me for following XL formula-
IF 10000, he is ultra-poor
IF 10001 to 15000, he is poor
IF 15001 to 25000, he is middle class
Thank you
Hi!
Carefully read the first paragraph of this article above. There is an answer to your question.
I am trying to do a nested if, and it is telling me I have too many arguments. In cell w2, i am inputting the word "yes", "no", or "probation". I wrote this formula. I am not sure where I have an error, Please help.
=if(w2, "yes", "APR Complete",
IF(w2, "no", "APR Needed",
IF(w2, "probation", "Not Applicable")))
Hi!
You can learn more about IF function syntax in Excel in this article on our blog.
You can use this formula:
=IF(W2="yes", "APR Complete",
IF(W2="no", "APR Needed",
IF(W2="probation", "Not Applicable")))
Hi
Thanks for an excellent article.
I have successfully managed to get the correct results for the first 3 conditions below. However with regards to IF(AD2>-10,"Big Loss", if the number is greater than -10, it still returns loss instead of "Big Loss"
What can I do to correct this in the formula below.
=IF(AD2>=10,"Big Profit",IF(AD2>0,"Profit",IF(AD2<=0,"Loss",IF(AD2<=-10,"Big Loss"))))
Many thanks,
Radley
Hello!
Swap last two conditions in nested IF function:
=IF(A2>=10,"Big Profit",IF(A2>0,"Profit",IF(A2<=-10,"Big Loss",IF(A2<=0,"Loss"))))
Hope this is what you need.
Hi,
How to get the formula for the following scenarios
Qty Value Rate Rate 2 Required
18,508 25,96,571 140 - 140
21,716 14,15,208 65 225 65
Hi!
What do you want to calculate exactly? Your question is not entirely clear, please specify.
One number is inputted into column A in either A1, A2 or A3 and then that number is also displayed in column B in either B 1, B2 or B3. But which cell it shows in column B should depend on both the value of the number and the cell in column A it was entered into.
If A1 is lower than 0 then the number is displayed in B3.
If A1 is 0-100 then the number is displayed in B1.
If A1 is over 100 then the number is displayed in B2.
If A2 is lower than 0 then the number is displayed in B1.
If A2 is 0-100 then the number is displayed in B2.
If A2 is over 100 then the number is displayed in B3.
If A3 is lower than 0 then the number is displayed in B2.
If A3 is 0-100 then the number is displayed in B3.
If A3 is over 100 then the number is displayed in B1.
Any idea on how to program this in excel?
Hello!
You can use multiple conditions in a nested IF formula:
=IF(AND(A1>0,A1<100),A1,IF(A2<0,A2,IF(A3>100,A3,"")))
This is the formula for cell B1.
I also suggest carefully reading the recommendations in the article above.
Hi I need to calculate the following
If car is 1200cc or lower the and the following will apply and if the car is 1200 of higher the following will apply. Any help would be appreciated
1200cc or lower
up to 1500KM .3795 per KM
1501 to 14000KM .4109 per km
14001 to 25000 .2550 per km
1201cc or higher
up to 1500KM .3986per KM
1501 to 14000KM .4109 per km
14001 to 25000 .2550 per km
Your help would be greatly appreciated on this
Ollie
Hi!
Read carefully the following paragraph of the article - Using multiple IF statements in Excel (nested IF functions), it covers your case completely.
See this comment for the answer to a similar question.
Question. I have been racking my brain all night on this.
I have 3 pieces of information that are linked to a master table on another sheet.
I have A1 - Date Assigned
I have A2 - Goal date
I have A3 - Date completed
I want to be able to put in a date into assigned and on my tracker have it read "A" on my master tracker
I am able to calculate a goal date, but want it to show "D" if is goes past the goal date referenced in A2 on the master tracker.
And then I want to be able to put a date in A3 and then have it read "X" for when there is a date listed for completion on my master tracker.
In addition, I want to be able to notice if there are no dates in either A1, A2, or A3 that it just shows blank on the master tracker.
I hope that is enough information to go off of.
Thanks for your help.
Also worth noting I have tried to get a formula using =IF(Z6>=TODAY()-(W6*7),AJ6,IF(Z6<=TODAY()-(W6*7),AJ7,IF(AE6,AJ8, "")))
But it will only do the first two it won't allow my third argument to go.
Hi!
Based on your description, it is hard to completely understand your task. I recommend reading this guide: Using IF function with dates.
For example, the formula might look like this:
=IF(Sheet21!A2 < > "",IF(A2>Sheet21!A2,"D",""),"")
I have a calculation between 2 cells where, based on the sum, the value should change. If not true, then the value should = the calculated sum. This is the latest attempt but not working. Thanks in advance !
if(H39*0.5)+(H41*0.5)=1.0,"1", if(h39*.05)+(h41*0.5)=2.0,"2", if (h39*.05)+(h41*0.5)=3.0,"3")))
Hi!
I fixed the errors in the syntax of the IF function
=IF((H39*0.5)+(H41*0.5)=1,1, IF((H39*0.05)+(H41*0.5)=2,2, IF((H39*0.05)+(H41*0.5)=3,3)))
Hello, and thank you so much! Getting closer but not quite there.
The problem I have is the results field is formatted with a decimal. When the result is a whole number I do not want the .0 . I have solved for this by using "". However, if the result is not a whole number (1,2, 3.) then I need the calculation to show the results "as is" ( e.g. 0.5). Here is my latest attempt but still not working. Wondering if is should use "or"?... Thanks again!
=IF(H39*0.5+H41*0.5=1,"1",H39*0.5+H41*0.5),IF(H39*0.5+H41*0.5=2,"2",H39*0.5+H41*0.5),IF(H39*0.5+H41*0.5=3,"3",H39*0.5+H41*0.5)
Hi!
Change the number format to "General" and you won't see 0 in integers.
=H39*0.5+H41*0.5
Or use the text "1" instead of the number 1.
=IF((H39*0.5)+(H41*0.5)=1,"1",IF((H39*0.05)+(H41*0.5)=2,"2",IF((H39*0.05)+(H41*0.5)=3,"3",H39*0.5+H41*0.5)))
Hello again and thank you so much for your quick reponse!
Wonderful! I'm going to go with the cell format change to "General". I learned more about the nested IF statement through this exchange but it simplifies the formula, so thank you!
Have a wonderful day!