0% found this document useful (0 votes)
474 views

Excel Nested If

The document explains how to use nested IF statements and AND/OR functions in Excel formulas. Nested IF statements allow multiple logical tests and outcomes in one formula. AND functions check if multiple conditions are true, while OR functions check if at least one of several conditions is true. The document provides examples of IF/AND and IF/OR formulas to calculate bonuses based on conditions like popularity and salary. It warns against overly complex nested formulas that are difficult to understand and update.

Uploaded by

salehgig
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
474 views

Excel Nested If

The document explains how to use nested IF statements and AND/OR functions in Excel formulas. Nested IF statements allow multiple logical tests and outcomes in one formula. AND functions check if multiple conditions are true, while OR functions check if at least one of several conditions is true. The document provides examples of IF/AND and IF/OR formulas to calculate bonuses based on conditions like popularity and salary. It warns against overly complex nested formulas that are difficult to understand and update.

Uploaded by

salehgig
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Excel Nested IF’s Explained

SEPTEMBER 29, 2010 BY MYNDA TREACY 61 COMMENTS

Did you know we can use a nested IF formula to extend the number of logical
tests and therefore, possible outcomes? Simply put, this is multiple IF’s
nested in the one formula.

Prior to Excel 2007 the limit of IF's you could nest in one formula was 7. Excel
2007 has increased this to an outrageous 64. I say outrageous, because in
most cases if you’re using more than a few nested IF’s in one formula, there’s
most likely a more efficient way to perform your calculation. So don’t get
carried away nesting!

IF Formula
In a previous tutorial we looked at the IF function (singular), which is one of
the most versatile functions in Excel, but on its own you’re limited to only one
of two outcomes. That is, if the answer to the question I am asking is true, do
this, if not, do that.

Before we dive in to nested IF’s I want to recap our singular IF statement


example to remind us how the logic works:

=IF(The number of units in column D is >5,Then take the


Total $k x 10%, but if it’s not > 5 then take the Total
$k x 5%)
So, if the answer to the question is true, you get outcome 1, and if answer is
false you get outcome 2.

Nested IF Formula
Now let’s take a look at a more complex problem that a nested IF would solve.

In our spreadsheet below I’d like to enter the commission for each row in
column G. The commission rates are different for each region. I’ve listed the
different rates in columns I and J so it’s easier to follow.....and later we’ll make
the formula more dynamic using this table, but let’s walk before we run.

In Excel language our Nested IF statement would read:

= IF(logical_test, value_if_true, IF(logical_test,


value_if_true, IF(logical_test,
value_if_true, IF(logical_test,
value_if_true,.............so on and so on up to 64
iterations)
Let’s translate it into English by applying it to row B of our spreadsheet:

=IF(B2="Central", if so enter 3%, if not see if


B2="East", and if so enter 4%, if not see if
B2="North", and if so enter 5%, if not see if
B2="South", and if so enter 6%, if not see if
B2="West", and if so enter 7%, if not enter "Missing")
In Excel it would look like this:

=IF(B2="Central", 3%,IF(B2="East", 4%,IF(B2="North",


5%,IF(B2="South", 6%,IF(B2="West", 7%,"Missing")))))
In the above formula we’re telling Excel to put 3% in the cell if B2=”Central”, if
not move on to the next IF statement and so on. In the last IF statement,
IF(B2="West",7%,"Missing"), we tell Excel to enter the word 'Missing' in the
cell if all previous IF’s are false.

Alternatively we could instruct Excel to enter ‘0%’ or anything else we like in


place of ‘Missing’. Or, if we left this argument out altogether Excel would
enter the word ‘FALSE’ for us by default.

Let’s make it better

With the formula the way it is we’d have to manually update the percentages
for each region if we wanted to alter them. And then copy and paste the
revised formula down the column. A better solution would be to link to the
table in columns I & J. Then if we updated the percentages in column J, our
formula in column G would dynamically update.

For example:

=IF(B2="Central", $J$2,IF(B2="East", $J$3,IF(B2="North",


$J$4,IF(B2="South", $J$5,IF(B2="West",
$J$6,"Missing")))))
If we wanted to change a rate we’d simply change the rate in column J and it
would dynamically update our formula in column G.

You could take it one step further and link the IF statement to the region
names as well, but I’ll let you play around with that when you download the
practice spreadsheet.
Download the Workbook
Enter your email address below to download the sample workbook.

Get Workbook
By submitting your email address you agree that we can email you our Excel newsletter.

You’ll notice that the references to the rates in column J have $ signs prefixing
the column letter and row number. These are absolute references. You can
learn about absolute references in a previous tutorial and discover how they
can improve your productivity in Excel.

I know I said at the beginning that you shouldn’t use more than a few Nested
IF’s, and I’ve broken that rule here for the purpose of my example. In reality I
would use the VLOOKUP in this scenario as it’s a simpler formula for both the
user to interpret later on, and for Excel to compute.

Warning
Too many nested IF's can result in performance issues. In this tutorial you can
learn alternatives to nested IFs.
Excel IF AND OR Functions Explained
OCTOBER 2, 2010 BY MYNDA TREACY 756 COMMENTS

Excel IF AND OR functions on their own aren’t very exciting, but mix them up with the IF
Statement and you’ve got yourself a formula that’s much more powerful.

In this tutorial we’re going to take a look at the basics of the AND and OR functions and then put
them to work with an IF Statement. If you aren’t familiar with IF Statements, click here to read
that tutorial first.

AND Function
The AND function belongs to the logic family of formulas, along with IF, OR and a few
others. It’s useful when you have multiple conditions that must be met.

In Excel language on its own the AND formula reads like this:

=AND(logical1,[logical2]....)
Now to translate into English:

=AND(is condition 1 true, AND condition 2 true (add more


conditions if you want)
OR Function
The OR function is useful when you are happy if one, OR another condition is met.

In Excel language on its own the OR formula reads like this:

=OR(logical1,[logical2]....)
Now to translate into English:
=OR(is condition 1 true, OR condition 2 true (add more
conditions if you want)
See, I did say they weren’t very exciting, but let’s mix them up with IF and put AND and OR to
work.

IF AND Formula
First let’s set the scene of our challenge for the IF, AND formula:

In our spreadsheet below we want to calculate a bonus to pay the children’s TV personalities
listed. The rules, as devised by my 4 year old son, are:

1) If the TV personality is Popular AND

2) If they earn less than $100k per year they get a 10% bonus (my 4 year old will write them
an IOU, he’s good for it though).

In cell D2 we will enter our IF AND formula as follows:

In English first
=IF(Spider Man is Popular, AND he earns <$100k), calculate his
salary x 10%, if not put "Nil" in the cell)
Now in Excel’s language:

=IF(AND(B2="Yes",C2<100),C2x$H$1,"Nil")
You’ll notice that the two conditions are typed in first, and then the outcomes are entered. You
can have more than two conditions; in fact you can have up to 30 by simply separating each
condition with a comma (see warning below about going overboard with this though).

IF OR Formula
Again let’s set the scene of our challenge for the IF, OR formula:

The revised rules, as devised by my 4 year old son, are:

1) If the TV personality is Popular OR

2) If they earn less than $100k per year they get a 10% bonus.

In cell D2 we will enter our IF OR formula as follows:

In English first
=IF(Spider Man is Popular, OR he earns <$100k), calculate his
salary x 10%, if not put “Nil” in the cell)
Now in Excel’s language:

=IF(OR(B2="Yes",C2<100),C2x$H$1,"Nil")
Notice how a subtle change from the AND function to the OR function has a significant impact
on the bonus figure.

Just like the AND function, you can have up to 30 OR conditions nested in the one formula,
again just separate each condition with a comma.

Try other operators

You can set your conditions to test for specific text, as I have done in this example
with B2="Yes", just put the text you want to check between inverted comas “ ”.

Alternatively you can test for a number and because the AND and OR functions belong to the
logic family, you can employ different tests other than the less than (<) operator used in the
examples above.

Other operators you could use are:

 = Equal to
 > Greater Than
 <= Less than or equal to
 >= Greater than or equal to
 <> Less than or greater than

Warning: Don’t go overboard with nesting IF, AND, and OR's, as it will be painful to decipher
if you or someone else ever needs to update the formula in months or years to come.

Note: These formulas work in all versions of Excel, however versions pre Excel 2007 are limited
to 7 nested IF’s.

Download the Workbook


Enter your email address below to download the sample workbook.

You might also like