Logical functions – IF, Countif, Sumif
IF Function
The IF function is one of Excel's logical functions that evaluates a certain condition and returns the value
you specify if the condition is TRUE, and another value if the condition is FALSE.
Its format is:
=IF(Condition,True,False)
Another way of interpreting what the IF function is doing is:
=IF(This is true, do this, otherwise do this)
In the example below each person's sales figures acheived, are listed in the main table. An IF function is
used in column G to evaluate the Sales figure in column F to see if it has met the Threshold figure in
column C; if it has then 2% of the sales figure is calculated otherwise 1% of the sales fgure is calculated
Operators that can be used for your logical test:
Operator Explanation
= Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to
www.weareexcel.co.uk Page 1 of 4 call us on 020 71837740
Logical functions – IF, Countif, Sumif
Using IF to display text
The IF function can be used to display different information depending on the outcome of the condition test.
The resulting text will appear in the cell where the formula containing the IF function resides. In the
example below the If function will indicate where figures in a neighbouring column meet or exceed a
specific target.
If you only want text to appear if the result is true, you can
enter ““ (two double quotes) in the position for false – E.G.
=IF(C7>=$E$2,“Exceeded Target“,““)
www.weareexcel.co.uk Page 2 of 4 call us on 020 71837740
Logical functions – IF, Countif, Sumif
Nesting IF functions
If you need to make more than one decision before calculating an answer, you can nest or embed an IF
function inside an IF function. You use additional IF functions in place of the true component of the IF
function. If the result of the first conditional test is true, then the 2nd argumant is executed and that's it. If on
the other hand the result of the first conditional test is false, then the second (nested) IF function re
evaluates with a second conditional test.
This structure allows for multiple conditional tests to be run in the event of the precendeing test being false
Another way of thinking about what the nested Ifs do could be to say:-
=IF(This is true, do this, otherwise check if this is true, if it
is do this, otherwise check if this is true,if it is do this, for
everythng else do this)
Test the highest value first then keep going in the same direction.
For example, we first work out did they score over 85, then over 75,
thenover 70 and so on
Type your nested functions
Do not use the insert function feature as it's only really
designed for simple functions, not nested ones
www.weareexcel.co.uk Page 3 of 4 call us on 020 71837740
Logical functions – IF, Countif, Sumif
COUNTIF function
The COUNTIF function counts only those values in a list that meet a criteria you set in the function. For example
looking at the list below we can use the COUNTIF function to count all the YES entries in column I.
Why does my formula tell me it contains an error when
I finish typing it?
Remember the second argument after the comma, must
be enclosed with double speech marks “” for example
>20000 would be written “>20000”.
SUMIF function
The SUMIF function will allow you add up only those values that meet the criteria you set. For example in the data
above you could add up all the salaries above £20,000, thus:-
=SUMIF(H19:H44,”>=20000”)
Criteria – so
Data to be only add up
evaluated values where
this is true
www.weareexcel.co.uk Page 4 of 4 call us on 020 71837740