You are on page 1of 23

CONTENTS

Logical Functions
IF
AND
NOT
OR
Multiple Logic Function Examples
Lookup Functions
LOOKUP
VLOOKUP
HLOOKUP
MATCH
Basic Statistical Functions
AVERAGE
AVERAGEIF
AVERAGEIFS
COUNT
COUNTBLANK
COUNTIF
MAX
MIN
MEDIAN
MODE
Useful Maths, Text and Date Functions
SUM
SUMIF
SUMIFS
DATE
DAYS
FIND
ROUND
RAND
RANDBETWEEN
PROPER
LOGICAL FUNCTIONS

IF
This function checks whether a specified condition is true, and what it should return in the case of true
or of false. In Excel, the syntax is written as

=IF(logical_test, [value_if_true], [value_if_false])

Which means:
=IF(if this is true, then do this, otherwise do this)
Note: arguments written in closed brackets are optional.

Example 1:
If we want to test whether a cell says a word, for example Blue, we can use the IF function.

The cell B1 has the formula =IF(A1=Blue,Yes,No)


This means that if the cell A1 says Blue, return Yes (in cell B1), otherwise return No. Note: words
must be written in quotation marks in formulae, whereas numbers dont need to be, as shown in the
following example.

Example 2:
If we want to see whether a cell value is higher than a certain number, and then, if it is, show the
difference, we can use the IF function.

The cell B2 has the formula =IF(A2>300,A2-300,N/A)


This means that if the cell A2 is higher than 300, return the difference between the two values,
otherwise return the text N/A. Note: the formula has been applied to B3 and B4 to test A3 and A4
respectively by dragging the bottom right corner down.

AND
This function checks whether ALL of the specified conditions are true, and returns TRUE or FALSE.
In Excel, the syntax is written as

=AND(logical1, [logical2], ...)

Where logical1, logical2, ... , are conditions. If both (or all, if more than 2) conditions are true, the
formula returns TRUE. If any of the conditions are not true, the formula returns FALSE.

Example 3:
If we want to test whether a cell value is higher than a certain number, and also lower than another
number, we can use the AND function.

The cell B2 has the formula =AND(A2>100,A2<1000)


This means that if A2 is larger than 100 and also smaller than 1000, return TRUE, otherwise return
FALSE.

NOT
This function returns FALSE when the condition specified is true, and returns TRUE when it is false.
In Excel, the syntax is written as

=NOT(logical)

It can be used when you want to make sure a cell does not satisfy a certain condition. So,
=NOT(TRUE) returns FALSE and, for example, =NOT(1=1) returns FALSE.
Example 4:
If we want to test whether a cell value is not greater than a certain number, we can use the NOT
function.

The cell B1 has the formula =NOT(A1>300), which means return TRUE if A1 is not higher than 300.

OR
This function checks whether ANY of the conditions are true, and returns TRUE if any are, or FALSE
if none are. In Excel, the syntax is written as

=OR(logical1, [logical2], ...)

Where logical1, logical2, ... , are conditions. If any conditions are true, the formula returns TRUE. It
is similar to the AND function, which tests if all conditions are true, but instead tests if any one
condition is true.

Example 5:
If we want to know whether a cell value is either higher than a number, or lower than another number,
we can use OR.

The cell B1 has the formula =OR(A1>100,A1<-100), which says that if A1 is higher than 100 or
lower than -100, return TRUE.

MULTIPLE LOGIC FUNCTION EXAMPLES


Logical functions are used well together, such as using the IF function on functions that return TRUE
or FALSE. Remember that the IF function arguments say =IF(if this is true, then do this, otherwise do
this), so we can, for example, say that if an AND function returns TRUE, then do this, otherwise do
this.

Example 6:
If we want to say that, if a cell value is both higher than a number and lower than another number, we
return one text, and if it isnt both, we return another text, we can use the IF and AND functions
together.

Cell B1 has the formula =IF(AND(A1>0,A1<100),Within Range,Out of Range), which says


that if A1 is both higher than 0 and smaller than 100, return the text Within Range, and if one of the
two conditions is false, return the text Out of Range. A1 is higher than 0 but not lower than 100.

Example 7:
Now we want to test whether a cell is not higher than a certain number, for example 0, and is higher
than a certain number, for example -100. If it satisfies both of these conditions, we want to return
Within Range, and if it does not satisfy one of the conditions, we want to return Out of Range. We
use IF, AND and NOT.

The cell B1 has the formula =IF(AND(NOT(A1>0),A1>-100),Within Range,Out of Range).


Taking the calculation step by step, 200>0, so NOT(A1>0) returns FALSE, which means one of the
conditions for the AND function is false, so AND(NOT(A1>0),A1>-100) returns FALSE. This means
that the IF function returns the value for when the condition is false, which in this case is the text Out
of Range.

Example 8:
We can do the same using the OR function instead of AND. This means that instead of checking both
conditions are true, we are checking that one condition is true.
The cell B1 has the formula =IF(OR(A1<-100,A1>100),Within Range,Out of Range). Here, if
A1 is either smaller than -100 or higher than 100, the OR function returns TRUE, and B1 is Within
Range. If neither of the conditions are true, the OR function returns FALSE, and B1 is Out of
Range.
LOOKUP FUNCTIONS

LOOKUP
This function looks in a single row or column to find a value from the same position in another row or
column. In Excel, the syntax is written as

=LOOKUP(lookup_value, lookup_vector, [result_vector])

Which means:
=LOOKUP(the value being searched for, the range to search within, the range to return the result
from)
Note: the values in the range it searches in must be in ascending order (eg 0, 1, 2, ... or A-Z), and both
ranges must be the same size.
Note: if it cannot find the lookup_value, it will use the next smallest value. See Example 9.2.

Example 9.1:
If we wanted to look up the score of a student by using their student number, we can use LOOKUP.

The cell D3 has the formula =LOOKUP(157,A2:A6,B2:B6). In this example, we have chosen 157 as
the value to search for, chosen A2:A6 as the range to search within, and chosen B2:B6 (the scores) as
the range to return the result from. D3 shows that the score of student 157 is 87.

Example 9.2:
Here we lookup student 168, but there is no data for this value, so the function lookups the next
smallest value, which, in this example, is 161. The cell D3 now has formula
=LOOKUP(168,A2:A6,B2:B6).
VLOOKUP
This function looks in a range to find a value by its row. In Excel, the syntax is written as

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

Which means:
=VLOOKUP(the value being searched for, the array to search within, the column number of the value
you want to return, TRUE for approximate or FALSE for exact)
Where the column number is found by counting along from the first column used. Note: the array must
be the entire data, including both the column to search in and the column to return from.

Example 10:
We want to find the cost of a job for any given customer reference number.

The cell F3 has formula =VLOOKUP(F2,A2:C6,3,FALSE). We can create a sort of search box as
shown above. The VLOOKUP function in F3 searches for the number written in F2, and we have
specified A2:C6 as the array to search within (this includes the reference numbers AND the costs). It
uses the 3rd row (Cost) to find the returned value.
HLOOKUP
This function is similar to VLOOKUP, but it looks in a range to find a value by its column. In Excel, it
is written as

=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])

In a similar example to Example 10, we search for the cost of a job by reference number when the
data is laid out with headings going down.

Example 11:

The cell E6 has the formula =HLOOKUP(E5,B1:D3,3,FALSE).

MATCH
This function searches for an item in a range of cells, and returns the position of the item in the range.
In Excel, it is written as

=MATCH(lookup_value, lookup_array, [match_type])

Which means
=MATCH(the value you want to match, range of cells to search, choose -1 0 or 1)
Note: for the match_type, 1 means the function finds the largest value less than or equal to the
lookup_value; 0 means the function finds the first value exactly equal to the lookup_value; -1 means
the function finds the smallest value greater than or equal to the lookup_value. If left blank, 1 is
selected.

Example 12:
If we want to find how far into the day an item on a schedule is, we can use MATCH.

The cell B3 has the formula =MATCH(Seminar,B1:E1). We want to match the text Seminar to
find whereabouts in the order the seminar is. We have used B1:E1 as the array to look within. The
result shows that the seminar is the second item in the schedule.

Example 13:
We want to find the position of a number in a list of numbers. In this case, we want the exact number,
so we need to add 0 as the last argument.

The cell C2 has the formula =MATCH(97,A1:A6,0).


BASIC STATISTICAL FUNCTIONS

AVERAGE
This function returns the arithmetic mean of the values selected. In Excel, it is written as

=AVERAGE(number1, [number2], ...)

Example 14:
We want to find the average age of children in a sports club.

The cell C3 has the formula =AVERAGE(A2:A7). Here we havent entered individual numbers into
the formula, but have selected the range A2:A7 to average.

AVERAGEIF
This function returns the arithmetic mean of all the values in the range selected that meet a certain
condition. In Excel, it is written as

=AVERAGEIF(range, criteria, [average_range])

Where the range is the group of values to average from, the criteria is condition which must be met,
and the average_range is the actual set of values to average (if this isnt chosen, then it defaults to the
range).

Example 15.1:
We have a list of employees with different job types A, B or C. We want to average the salaries
based on their job type.
The cell C3 has the formula =AVERAGEIF(A2:A9,=B,B2:B9). In this example, we have selected
A2:A9 as the range to look for the condition in, which we have chosen as equalling B, and have
chosen the range to average as the salary column. This has given us the average of all salaries of type
B.

Example 15.2:
We can use the same data but we now make the condition that we only average values over 20,000.

The cell C3 has the formula =AVERAGEIF(B2:B9,>20000). We havent entered a third argument
because the criteria is related only to the salary column, so it will automatically choose the salary
column to average values from.

AVERAGEIFS
This function returns the arithmetic mean of all the values in the range selected that meet multiple
conditions. In Excel, it is written as

=AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2], ...)

Meaning
=AVERAGEIFS(range to average, range to evaluate the criteria1 in, the first criteria, optional: range
to evaluate criteria2, the second criteria,...)

Example 15.3:
Following on from the previous example, if we can also categorise the employees by their group, X,
Y or Z, then we can average the salaries of employees within a certain type AND group.

The cell D4 has the formula =AVERAGEIFS(C2:C9,A2:A9,=A,B2:B9,=Y). We have selected


the salaries as the range to average from, the type as the first condition range, and specified A, and the
group as the second condition range, and specified Y. The result is the average of salaries with both
type A and group Y.

COUNT
This function counts the quantity of cells which contain numbers, within a range. In Excel, it is written
as

=COUNT(value1, [value2], ...)

Value1 is the range within which you want to count the quantity of numbers. Value2 is optional and
can be another range or item.

Example 16:
We want to count the amount of numbers within a list of numbers and letters.
The cell B2 has the formula =COUNT(A1:A7), so it is counting the amount of number characters in
the list in column A. Note: the second argument, value2, can be used to add another range of cells to
count.

COUNTBLANK
This function counts the quantity of blank cells within a range. In Excel, it is written as

= COUNTBLANK(range)

The range is the array of cells within which you want to count the empty cells.

COUNTIF
This function counts the quantity of cells that meet a certain condition. In Excel, it is written as

=COUNTIF(range,criteria)

The range is where you want to search, and the criteria is what you want to search for.

Example 15.4:
Going back to Example 15 again, we can count the number of employees who have a salary of value
higher than 21,000.
The cell C3 has the formula =COUNTIF(B2:B9,>21000). The range is the salary column, and the
criteria is that it is higher than 21,000.

MAX
This function gives the largest value from a range or set of numbers. In Excel, it is written as

=MAX(number1, [number2], ...)

MIN
This function gives the lowest value from a range or set of numbers. In Excel, it is written as

=MIN(number1, [number2], ...)

MEDIAN
This function gives the median value (the middle value) from a range or set of numbers. In Excel, it is
written as

=MEDIAN(number1, [number2], ...)

MODE
This function gives the mode (the most frequently occurring number) from a range or set of numbers.
In Excel, it is written as

=MODE(number1, [number2], ...)


USEFUL MATHS, TEXT AND DATE FUNCTIONS

SUM
This function adds together the values entered or the values in a specified range. In Excel, it is written
as

=SUM(number1, [number2], ...)

For example, =SUM(A2,A8) to add A2 and A8, or =SUM(A1:A12) to add all the values from A1 to
A12.

SUMIF
This function adds together the values in a specified range that meet a certain condition. In Excel, it is
written as

=SUMIF(range, criteria, [sum_range])

Example 15.5:
If we go back to our Example 15, we can sum the salaries of employees which are of type C.

The cell D4 has the formula =SUMIF(A2:A9,=C,C2:C9). We have specified our criteria range as
A2:A9 (the type column), and said we want only type C, and chosen the sum range as C2:C9 (the
salary column). The result is the sum of all of the salaries of employees of type C.

Example 15.6:
The cell D4 has the formula =SUMIF(C2:C9,>20000). In this example, we have summed the
salaries which are higher than 20,000. Our criteria is based on the values we are summing so we only
need one range.

SUMIFS
This function adds together the values in a specified range that meet multiple conditions. In Excel, it
is written as

= SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)

Meaning
=SUMIFS(range to average, range to evaluate the criteria1 in, the first criteria, optional: range to
evaluate criteria2, the second criteria,...)

Example 15.7:
Using Example 15 again, we can sum the salaries of employees by both type and group.
The cell D4 has the formula =SUMIFS(C2:C9,A2:A9,=B,B2:B9,=Z). Weve said that the sum
range is the salary column, that the first criteria depends on the type column, and specified B, and that
the second criteria depends on the group column, where weve specified Z. D4 shows the salaries of
employees in both type B and group Z added together (which is just one employee in this case).

DATE
This function returns the date from the entered year, month and day. In Excel, it is written as

=DATE(year, month, day)

For example, =DATE(2017,08,31) returns 31/08/2017. Note: =TODAY() returns todays date.

DAYS
This function returns the number of days between two specified dates. In Excel, it is written as

=DAYS(end_date, start_date)

Example 17:

The cell B1 has the formula =DAYS(01/12/2017,01/12/2016). So weve searched for the
number of days between 01/12/2016 and 01/12/2017, which is 365.
FIND
This function returns the position of a searched character or text in a string of text. In Excel, it is
written as

=FIND(find_text, within_text, [start_num])

Meaning
=FIND(the text to find, within this text, optional: starting at which position)

Example 18.1:
Within a name, we want to find the position of the first letter E.

The formula in cell B1 is =FIND(E,A1) and returns 1, as E is the first letter.

Example 18.2:
If we want to find the position of the letter E starting from the 5 characters in, we add the third
argument.

This formula in cell B1 is =FIND(E,A1,5) and the search has started from the 5th character, so the
next E is in position 7.

ROUND
This function rounds a number to a specified number of digits. In Excel, it is written as

=ROUND(number, num_digits)
RAND
This function returns a random real number greater than or equal to 0, and less than 1. Note:
everytime the worksheet is recalculated, a new random number will be returned. This function has no
arguments.

RANDBETWEEN
This function returns a random integer between 2 specified numbers. Note: as with RAND, the
number will change whenever the worksheet is recalculated. In Excel, it is written as

=RANDBETWEEN(bottom, top)

Example 19:
We want a random integer between 5 and 20.

The cell B1 has the formula =RANDBETWEEN(5,20), which returns a random integer between
these two bounds.

PROPER
This function puts a string of text into proper format, meaning it capitalises the first letter and
converts the others to lowercase. In Excel, it is written as

=PROPER(text)

Example 20:
We have 3 names we want in proper form.

You might also like