Nested Ifs, IF (AND), IF (OR) : Modelling: Contents
Nested Ifs, IF (AND), IF (OR) : Modelling: Contents
Nested Ifs, IF (AND), IF (OR) : Modelling: Contents
IF(AND), IF(OR)
MODELLING : CONTENTS
• Nested IF formulae
• IF(Or…..) formulae
• IF(And…) formulae
Wherever you see this symbol, make sure you remember to save your work!
A simple IF…Then statement is where there is a TRUE or FALSE condition. These are the
ones that you are more likely to come across so it is important that you know how to write
these.
However, some situations might require you to be able to write a Nested IF statement.
They may look long and complicated, but they are really quite simple once you understand
the concept.
=IF("if this condition stated here is true", then enter "this value, else if("if this
condition stated here is true", then enter "this value, else enter"this value"))
You may have a spreadsheet that you use to keep track of the rate of commission that
your sales team earns. You may not want to pay a flat rate of commission, perhaps it is
fairer to pay more commission to those sales people who have worked harder and sold
more items.
TASK 1
We need to write our nested IF so that we can find out the correct
commission they should earn.
=IF(B2<=10,$B$9,IF(B2<=100,$B$10,$B$11))
=IF(B2<=10,
This first part looks at the data in cell B2, which is Johns’ sale. It then says, ‘If Johns sales
are less than or equal to 10
=IF(B2<=10,$B$9,
Notice that an absolute cell reference has been used for B9 – otherwise when you drag it
down, you would get the wrong values.
=IF(B2<=10,$B$9,IF(B2<=100,
This part says, IF Johns’ sales in B2 are less than or equal to 100
=IF(B2<=10,$B$9,IF(B2<=100,$B$10,
If they are less than or equal to 100, then you tell the formula what you want displayed, in
this case, it is the corresponding commission for sales over £11 up to £100 – Cell B10
(remember to use an absolute cell reference again).
=IF(B2<=10,$B$9,IF(B2<=100,$B$10,$B$11))
The final part of the formula says what should happen if neither of the first two conditions
are met, i.e. sales are not £1-£10, nor are they £11-£100.
=IF(B2<=10,$B$9,IF(B2<=100,$B$10,$B$11))
You have one set of brackets for the first IF condition: =IF(B2<=10,$B$9,
You then open another set of brackets for the second IF condition:
=IF(B2<=10,$B$9,IF(B2<=100,$B$10
Because you have two sets of opening brackets, just the same as in maths, you must have
two sets of closing brackets:
=IF(B2<=10,$B$9,IF(B2<=100,$B$10,$B$11))
Once you have written your first statement, drag the formula down through cells C3:C5.
Check that the correct rates of commission have been displayed.
TASK 2
• 49 or below = Fail
• 50 to 74 = Pass
• 75 or above = Distinction
=IF(B2>=75,”Distinction”,
IF(B2>=50,”Pass”,
“Fail”))
=IF(B2>=75,"Distinction",IF(B2>=50,"Pass","Fail"))
Have a go yourself.
Not working?
If something goes wrong, it is usually because you have missed a comma, speech marks or
a bracket.
Notice, we did not need to use any absolute cell references in this formula as we were
typing in the conditions ourselves and not referencing another cell on the spreadsheet.
Information:
• If the home result is greater than the away result, we want to display ‘Home’
• If the home result is the same as the away result, we want to display ‘Draw’
• If the away result is higher than the home result we want to display ‘Away’.
Remember – any words e.g. home, away or draw must be enclosed in speech marks for
Excel to accept them.
In cell E1, have a go at writing your nested IF statement – here is a little hint to start you
off:
=IF(B2>D2,”Home”,
When you have written your formula, drag it down to cells E3 and E4.
We need to be able to pick up the correct price per minute for ‘peak call charges’ from
the Tariff table depending on which tariff has been chosen in cell D1 (in this case tariff C).
Remember, that A, B or C will need speech marks around them in your formula. Also
remember that you need two sets of opening and two sets of closing brackets.
In cell C4, have a go at writing your nested IF formula, taking into account the information
above.
Now that you have worked out your formula for peak call charges, you need to write
another nested IF formula to work out off-peak call charges.
Using the same information shown above, in cell C5, write a nested IF that finds the
correct off-peak rate from the Tariff table.
In D4 write a formula to calculate the peak call charges (minutes * price per minute)
In D5 write a formula to calculate the off peak call charges (minutes * price per minute)
In cell D6 you need to write another nested IF formula to pick up the correct line rental
from the Tariff table.
In cell D8 calculate the VAT payable by multiplying the total costs (D7) by 0.175 or 17.5%
In cell D9 write a formula to calculate the total costs and the VAT payable.
Set your print area and ensure that your work is set to print on one page.
Logical functions can also be included in IF statements. It is also important that you
understand how these functions work.
=IF(OR("if this condition stated here is true", or "if this condition stated here is true”),
then enter "this value", else enter "this value")
You may have a spreadsheet that you want to use to work out whether or not a pupil
should be entered for a higher Maths paper in their exams.
In this example, pupils have sat two Maths papers. In order to be entered for the higher
paper, they must have achieved at least 75 marks in each of the two modules.
TASK 5
=IF(OR(
This first part says that we want to check whether either of the conditions that follow are
satisfied.
=IF(OR(B3<75,
=IF(OR(B3<75, C3<75),
This part checks whether or not the value in cell C3 is less than 75. (The minimum mark to
sit the higher paper in module 2 is also 75 – so any value less than 75 will not be
accepted). If the value in cell C3 is less than 75 then TRUE is stored.
If either of the conditions, B3<75 or C3<75, is TRUE, then the word foundation will be
displayed. It is important that any text you want to display is enclosed in speech marks.
The final part of the formula displays higher if either of the conditions has not been met
i.e. neither of the marks for the modules were less than 75. The word Higher will then be
displayed.
You then open another set of brackets for the OR condition: =IF(OR(
Another bracket, ends the OR condition, with another ending the IF condition:
Once you have written your first statement, drag the formula down through cells D3:D7.
Check that the correct papers have been assigned to the pupils.
• a list of items
• how many of each are in stock
• what the level needs to be to
order more
• Whether the item is selling
particularly fast
We are now going to write an IF(OR) statement to determine whether or not each item
needs to be re-ordered.
=IF(OR(
We now need to write a condition, to work out whether the quantity in stock is less than
the re-order level: =IF(OR(B2<C2,
We now need to determine whether the item is selling fast, add this to the statement:
If either condition is true, then the item needs re-ordering. Enter the word “Yes” if it
does, “No” if not:
The IF(AND) function is very similar to the IF(OR) function. However, rather than either of
the conditions being satisfied, both conditions must be satisfied.
=IF(AND("if this condition stated here is true", and "if this condition stated here is
true”), then enter "this value", else enter "this value")
TASK 7
The example in task 5 can be re-written using this function to determine the answer.
=IF(AND(
This first part says that we want to check the whether both the conditions that follow are
satisfied.
=IF(AND(B3=>75,
Here we want to check whether the value in cell B3 is equal to or greater than 75 i.e. they
have got enough marks for this module to be entered for the higher paper.
=IF(AND(B3=>75, C3=>75),
This part checks whether the value in cellC3 is equal to or greater than 75 i.e. they have
got enough marks for this module to be entered for the higher paper.
If one of the conditions, B3=>75 C3=>75 is not satisfied, then the word higher will be
written.
Write this statement into cell E3, and fill down – check it gives you the same answer as in
column D.
TASK 8
Make sure that you have entered the data in cells A10:B12
You now need to work out whether or not each pupil can be put into set 2 for their Maths
lessons. Put a title in cell C1 saying ‘Maths Set’.
Now have a go at entering an IF(AND) statement into cell C2 to decide. (NB. Be careful
with absolute referencing).
If the pupil qualifies to be in set 2, write “set 2”, if not write “another set”.
Now that you have worked out what set each pupil should be in, add another column to
work out whether any of the pupils deserve a commendation. If they achieve higher than
90 marks, “commendation” should be entered. If their mark does not deserve a
commendation, then leave the cell empty. To do this just type “”, for what to display.
Note: The words to be displayed should not be entered, the cells that contain the words
should be used.
This column is to display whether any action needs to be taken for this pupil.
Write an if(AND) statement in this column. If both pieces of work from week 1 and week 2
were late, the word ‘detention’ should be written (get this from the cell, do not type it
in). If there is no action to be taken, leave the cell empty i.e. as before type “”.
You may:
• Guide teachers or students to access this resource from the teach-ict.com site
• Print out enough copies to use during the lesson
A subscription will enable you to access an editable version, without the watermark and save it
on your protected network or VLE