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,
So I am trying the IF function with mathematical equation in it.
I have got a drop down list with two options: A & B
and below there are 4 variables: 1,2,3,4
So what i am trying to do is, if someone selects option A, then i want the formula 1*2 to be applied, and if someone selects option B then i want the formula (1*2*3)/4 to be applied
Is there a way around?
Many thanks in advance
Hi! How to create your formula is detailed in the article I recommended. It might look like this:
=IF(A1="A",C1*C2,IF(A1="B",C1*C2*C3/C4,""))
You can also use the IFS function instead of multiple IF:
=IFS(A1="A",C1*C2,A1="B",C1*C2*C3/C4)
I'm trying to exclude any 0's from N19 and L19 in this IF function: =IF(AND(N19<5,L19<5),"Watchlist","")
Hi! From your description, it is difficult to have a full understanding of your task. I’ll try to guess and offer you the following formula:
=IF(AND(N19<5,L19<5,N19<>0,L19<>0),"Watchlist","")
If I haven't guessed, explain the problem in detail.
Dear sir,
My condition 0-240 WORKING =15DAYS
0-239 WORKING=0 DAYS
400 Above days working =30days this condition if formula required please tell me
Hi! Please re-check the article above since it covers your task. You can also find useful information in this article: Excel Nested IF statements - examples, best practices and alternatives.
I cannot recommend the formula because the first and second conditions contradict each other.
Hi,
I've tried a few different formulas for CPP calculation to include the new CPP2 contribution level and continue to get a formula error.
This is the latest formula I have put together
IF(I10>35006850073200,4055.50)))),0)
Thank you
Formula did not come over well the first time
=IF(I10>35006850073200,4055.50)))),0)
formula is not showing properly after I click 'send'
Hi! I recommend studying the IF function syntax.
=IF(I10>35006850073200,4055.5,0)
salary tax calculate
first 100,000 no tax and and first 50,000 6% tax,
2 nd 50,000 12% tax
3rd 50,000 18% tax
4 th 50,00 24% tax
and 5th 50,000 and over 36% tax,
how can caluculate tax if the monthly salary 500,000
thanking you
Hi! I think you'll find these recommendations and these advices in the comments on our blog helpful.
Staff Current Date 10/29/2023
Staff ID First Name Last Name Date of Birth Age Classification Pay Rate
N00011 Sally Jenkins 5/6/1998 25
N00012 David Nugyen 04/24/1981 42
N00013 Natalie Dinatale 3/19/1999 24
N00014 CameronJohnson 8/21/1991 32
N00015 Justine Lee 01/15/2004 19
Staff Classifications
Age Classification Description Ordinary Payrate
16 Junior 1 Junior wage - 16 yo $ 8.23
17 Junior 2 Junior wage - 17 yo $ 9.88
18 Junior 3 Junior wage - 18 yo $ 11.52
19 Junior 4 Junior wage - 19 yo $ 13.17
20 Junior 5 Junior wage - 20 yo $ 14.82
21 Adult Full adult wage $ 16.47
1. Make the following changes to the spreadsheet to enable the correct salary classification to be determined.
a. Add a formula in E1 to calculate the current date.
b. Add a formula to cells E3:E7 that calculates the age of the staff member as at the current date.
c. Add a formula to cells F3:F7 that displays the salary classification.
d. Add a formula to cells G3:G7 that displays the correct pay rate that applies to each staff member.
PLEASE HELP ME
Hi! You can find the answer to "A" in this article: How to insert today's date in Excel. Answer to "B": How to calculate age in Excel. The rest of the questions are unclear. Ask your teacher what needs to be done.
question C and D are asking me to put a formular based on information from staff classifications
Please help me google sheet stock market value formula:
Example
A1 is 943 (Current Stock price)
B2 is 951 (Ema of the current stock price)
How to i make C1 Column to know the stock price (+ or - 0.5%) near the EMA value.
Currently am using C1 Column as: =AND(A1=B2-5)
This will give the results when the stock price reached near by EMA Price +5 or -5 as True or False. Instead of this I would like to have +0.5% or -0.5% in the above formula, I need percentage wise, please help me.
Hi! To increase the number by 0.5%, use the formula B2*1.005 or B2*100.5%
Read more: Increase / decrease a number by percent.
3 days i have tried to solve this and now you saved my day. :) Thank you for using your remarkable talents and skills to fuel our mutual efforts.
Hello, One part of this formula isn't calculating and i'm unsure why.
B4 = drop down list
E4 = Body Weight.
All except "cat" will calculate the result in another cell??
=IF(B4="Cat",53*E4^0.711,IF(B4="MALE NEUTERED",70*E4^0.75,IF(B4="FEMALE ENTIRE",70*E4^0.75,IF(B4="FEMALE NEUTERED",60*E4^0.75,IF(B4="MALE ENTIRE",80*E4^0.75,"")))))
I can't understand your formula and check it as I don't have your data. I can't guess what result you wanted to get.
I like this content
I need help with a very complicated formula please.
I need to get the points earned for a specific task, but I need the formula to return the value based on multiple cells.
For example,
If on this date, for Tier 2 the Issue was 4. I need the formula to look down the issue line (1-30) and find Issue 4, then find Tier 2 value (2.87) Then see f there are any kicker points (in this case Kicker A=0.8 and Kicker C = .04) and multiply 4 issues by the Tier value then add Kicker points. The total in this case would be 12.68. I arrived to that value by doing separate computations but I know there must be a better way than to have several tables computing different values.
Please help - smile
Thank you so much.
KICKER POINTS
0.8 0.4 0.4 0.4 1.2
DATE ISSUES TIER 0 TIER 1 TIER 2 TIER 3 TIER 4 ISSUE PTS A B C D E TOTAL
09/01/2023 1 3.86 2.14 1.64 1.25 0.6
09/02/2023 2 4.67 2.54 2.07 1.61 0.7
09/03/2023 3 5.44 3.02 2.5 1.93 0.8
09/04/2023 4 6.22 3.42 2.87 2.2 0.9 11.48 X X 12.68
09/05/2023 5 7 3.78 3.2 2.44 1
09/06/2023 6 7.23 4.1 3.49 2.66 1.1
09/07/2023 7 7.47 4.4 3.76 2.86 1.2
09/08/2023 8 7.7 4.67 4.02 3.05 1.3
09/09/2023 9 7.94 4.93 4.25 3.22 1.4
09/10/2023 10 8.17 5.17 4.48 3.38 1.5
09/11/2023 11 8.41 5.4 4.69 3.54 1.6
09/12/2023 12 8.64 5.63 4.89 3.69 1.7
09/13/2023 13 8.88 5.83 5.09 3.82 1.8
09/14/2023 14 9.11 6.03 5.29 3.95 1.9
09/15/2023 15 9.35 6.23 5.48 4.08 2
Hi! Your request goes beyond the advice we provide on this blog. This is a complex solution that cannot be found with a single formula. If I understand your task correctly, the following tutorial should help: INDEX MATCH MATCH in Excel for two-dimensional lookup.
If you have a specific question about the operation of a function or formula, I will try to answer it.
Hi all, I'm having an issue trying to "stack" multiple possibilities to come up with a text string depending on data in specific cells. Basically, I have Column C1-6, and I'm trying to get a formula where if there is a NAME in cells C1 & C2, the output would be "NAME1 and NAME2"; if there is a NAME in Cells C1, C2 and C3, the output would read "NAME1, NAME2, and NAME3"; if there is a NAME in cells C1-4, the output would be "NAME1, NAME2, NAME3, and NAME4"; et cetera. I can't seem to get past two without messing it up somewhere and would really appreciate some help. Below is the closest I've gotten to making it work but something in there is giving me an incomplete answer after two inputs. Thanks in advance for any advice.
=Rent!C4&IF(Rent!C7="","",IF(Rent!C10=""," and "&Rent!C7&IF(Rent!C13="","",", "&Rent!C7&", and "&Rent!C10&IF(Rent!C16="","",", "&Rent!C7&", "&Rent!C10&", "&Rent!C13&", and "&Rent!C16&IF(Rent!C19="","",", "&Rent!C7&", "&Rent!C10&", "&Rent!C13&", "&Rent!C16&", and "&Rent!C19)))))
Hi! To combine cell values into a text string, I recommend using the TEXTJOIN function. Read more: TEXTJOIN function in Excel to merge text from multiple cells. Try this formula:
=TEXTJOIN(",",TRUE,A1:A6)
Thank you for that recommendation. I found another way to do what I was trying to do, but will look into the TEXTJOIN function as I'm not familiar with that.
=SUMIF(B21,"=",M21)*OR(B21,"",O21)+B21*B13*3
How do I take this formula and make it pick one total value?
Right now it is multiplying all of them together and it either or.
If the flow is under 556,000 then its =SUMIF(B21,"=",M21)*OR(B21,"",O21)+B21*B13*3
All together it multiplies them together.
I need it to pick one that fits.
can this be achieved in a formula or would I need to do it another way?
thanks much.
Hi! From your explanation it is very difficult to understand what you want to calculate. But I think these guidelines may help you: How to use Excel SUMIFS and SUMIF with multiple criteria. If this is not what you wanted, please describe the problem in more detail.
Hi,
I need a formula that help me get data from multiple conditions.
For Example:
1.First cell contains (from Data validation) = UNITS & VALUE.
2.Second cell contains (from Data validation) = TOTAL LEVEL,DEPARTMENT LEVEL,BRAND LEVEL,CLASS LEVEL,ARTICLE LEVEL,PROGRAM LEVEL.
3.Third cell contains (Lookup from 2nd cell) = If "total" then data must be in total, If "Dept" then Data must be at dept "Dept Level" and carry on..
I can share sheet as well for reference.
For multiple conditions, instead of multiple IF, use the IFS function.
IFS(B2=" TOTAL LEVEL", [reference or formula], B2="DEPARTMENT LEVEL", [reference or formula], ...)
Am having a dataset on google sheet, i want to calculate, employees whose ages are = or less than 20, 30, 40, 45, 50 knowing fully well one column contains the ages of all the employees
Hello Paulson,
If you work in Google Sheets, check this tutorial on the IF function with numbers.
Thank you Svetlana ,
I'm just finishing one of most challenging Complicated formula with 29 Nested IF .
My advice to Draw a flow chart to build up your logic and your sequence .
Whatever the Problem is Complected , Once you Build a flowchart , you will figure your way .
I am trying to figure out how to use the IF function to calculate commission, but in a range of sales. There has to be an additional function.
The difference is the the commission goes down as the sales increase in a range.
The first $50k pays 4.75%
The next 51K to $150k pays 3%
Everything over 150K pays 1.5%
So, with $1,000,000 of sales
$50,000.00 @ 4.75% $2,375.00
$100,000.00 @3% $3,000.00
$850,000.00 @ 1.5% $12,750.00
Total Commission $18,125.00
Hi! See the answer in the first paragraph of the article above.
1st One thousand COD Charge 20 Taka
Next Per thousand COD charge 8 Taka
0-1000= 20 Taka
1001-Above= 8 Taka, Per thousand Charge
So which formula I used this Case
Plz hep me
Read the first paragraph of this article carefully.
Hello again,
Further to my recent comment, I have resolved my problem by using the IF, AND functions together.
Thank you for your posts as I often resolve problems from reading your answers in these pages.
Many thanks
Hello,
In columns B and C I have used the IF Function to return the values "High" or "Low".
Now, from these two columns I need to return the following values in column D.
B C Value in D
4 High High Star
5 High Low Puzzle
6 Low High Plow horse
7 Low Low Dog
I am not sure which function would be best here, thanks in advance.
Hi! Please re-check the article above since it covers your task.
in if command two value is same and name is different how to solve this problem. for example, if b2=82," Pakistan" ,if b2=82," India" in my sheet both value count is same. how to resolve this issue plz guide.
I am not sure I fully understand what you mean.
I don't havve no. but percentages
18.18%
18.58%
15.86%
15.09%
19.35%
16.14%
I want to use if function fot low, okay, good
As it's currently written, it's hard to tell exactly what you're asking.