Excel Adv Formulae & Functions
Excel Adv Formulae & Functions
Excel 2003
Advanced Excel
Formulae &
Functions
Introduction........................................................................................................ii
CONVERT................................................................................................ 1
Database functions.................................................................................2
Creating the criteria range 2
Entering a database function on the worksheet 3
Logical functions.................................................................................... 5
IF statements 5
Nested IF 6
Statistical IF statements 6
AND, OR, NOT 7
Financial functions................................................................................. 9
Future Value function (FV) 9
Present Value function (PV) 10
Net Present Value (NPV) 11
RATE 12
Payment function (PMT) 13
Data tables............................................................................................ 14
One-input data table 14
Two-input data table 15
Learning more...................................................................................................16
Function Purpose
DCOUNT(Database,Field,Criteria) To count the number of records in a list which meet specified
criteria. This function will only count value cells.
DCOUNTA(Database,Field,Criteria) To count the number of records in a list which meet specified
criteria. This function counts text and value cells.
DSUM(Database,Field,Criteria) To add the contents of the chosen field in a list, subject to any
specified criteria.
DMIN(Database,Field,Criteria) To find the minimum value in the chosen field in a list, subject to
any specified criteria.
DMAX(Database,Field,Criteria) To find the maximum value in the chosen field in a list, subject to
any specified criteria.
DAVERAGE(Database,Field,Criteria) To find the average value of the chosen field in a list, subject to
any specified criteria.
DGET(Database,Field,Criteria) To return the contents of the chosen field subject to any
specified criteria. This function is only valid where a single
record meets the criteria set.
DPRODUCT(Database,Field,Criteria) To multiply the contents of the chosen field in a list, subject to
any specified criteria.
Field indicates which column is used in the function. Columns of data in the
list must have an identifying label in the first row. Field can be given as
text with the column label enclosed between double quotation marks,
such as "Department" or "Age" in the example list below, or as a
number that represents the position of the column in the list: 1 for the
first column (First in the example below), 2 for the second (D.O.B),
etc. You can also use the cell reference that contains the column label
(F6 in the example below).
Criteria is a reference to a range of cells that specify conditions for the
function. The function returns information from the list that matches
the conditions specified in the criteria range. The criteria range
includes a copy of the column label in the list for the column you want
the function to summarise. The criteria reference can be entered as a
cell range, such as B1:F2 in the example database below, or as a name
that represents the range, such as "Criteria".
In all cases, if the criteria range is blank, these functions will apply to the
entire list area. Once data is entered in the criteria range, the results of the
database functions will adjust to reflect only those records meeting the criteria.
Helpful hints:
Although the criteria range can be located anywhere on the worksheet, do not place the criteria range below
the list. If you add more information to the list by using the Form command on the Data menu, the new
information is added to the first row below the list. If the row below the list is not blank, Excel cannot add the
new information.
Make sure the criteria range does not overlap the list.
Note that if you change criteria, existing answers will change. To keep existing answers, create a new criteria
range for subsequent queries.
To perform an operation on an entire column in a database, enter a blank line below the column labels in the
criteria range.
The field may be entered as a number or as text. If the field on which the
function is to operate is the fifth column within the database, you could enter
the number 5 as the field argument. Alternatively, the field name could be
entered as text, in which case it would need to be enclosed in double quotes:
=DMAX(database,"age",criteria)
In the example below, the formula shown on the Formula bar has been entered
into the cell to the right of the label Average. This formula averages the Age
column. All the database functions look at what has been entered in the criteria
range in order to give their results.
Criteria
range
List Field
range name
Logical functions
Excel has a number of logical functions, which allow you to set various
conditions and have data respond to them. For example, you may only want a
certain calculation performed, or piece of text displayed, if certain conditions
are met. The functions used to produce this type of analysis are found in the
Insert Function dialog box in the Logical function category.
IF statements
The IF function is used to analyse data, test whether or not it meets certain
conditions and then act upon its decision. The formula can be entered either by
typing it or by pasting it from the Formula, Paste Function box. Typically, the IF
statement is accompanied by three arguments enclosed in one set of
parentheses; the condition to be met (logical_test); the action to be performed
if that condition is true (value_if_true); the action to be performed if false
(value_if_false). Each of these is separated by a comma, as shown:
=IF( logical_test , value_if_true , value_if_false)
Logical test
This part of the IF statement is the condition, or test. You may want to test to
see if a cell is a certain value, or to compare two cells. In these cases, symbols
called logical operators are useful:
Therefore, a typical logical test might be B1 > B2, testing whether or not the
value contained in cell B1 of the spreadsheet is greater than the value in cell
B2. Names can also be included in the logical test, so if cells B1 and B2 were
respectively named SALES and TARGET, the logical test would read SALES >
TARGET.
Another type of logical test could include text strings. If you want to check a
cell to see if it contains text, that text string must be included in quotation
marks. For example, cell C5 could be tested for the word YES as follows;
C5="YES".
It should be noted that Excel's logic is, at times, brutally precise. In the above
example, the logical test is that sales should be greater than target. If sales are
equal to target, the IF statement will return the false value. To make the logical
test more flexible, it would be advisable to use the operator > = to indicate
meeting or exceeding (greater than or equal to).
Value if true / false
Provided that you remember that the TRUE value always precedes the FALSE
value, these two values can be almost anything. If desired, a simple number
could be returned, a calculation performed, or even a piece of text entered.
Also, the type of data entered can vary depending on whether it is a true or
false result. You may want a calculation if the logical test is true, but a message
displayed if false. (Remember that text to be included in functions should be
enclosed in quotes.)
Nested IF
When you need to have more than one condition and more than two possible
outcomes, a nested IF is required. This is based on the same principle as a
normal IF statement, but involves nesting a secondary formula inside the main
one. The secondary IF forms the FALSE part of the main statement, as follows:
=IF(1st logic test, 1st true value, IF(2nd logic test, 2nd true value, false
value))
Only if both logic tests are found to be false will the false value be returned.
Notice that there are two sets of parentheses, as there are two separate IF
statements. This process can be enlarged to include more conditions and more
eventualities up to 7 IFs can be nested within the main statement. However,
care must be taken to ensure that the correct number of parentheses are
added.
Statistical IF statements
A very useful technique is to display text or perform calculations only if a cell is
the maximum or minimum of a range. In this case the logical test will contain a
nested statistical function (such as MAX or MIN). If, for example, a person's
sales cell is the maximum in the sales column, a message stating "Top
Performer" could appear next to his or her name. If the logical test is false, a
blank message could appear by simply including an empty set of quotation
marks. When typing the logical test, it should be understood that there are two
types of cell referencing going on. The first is a reference to one person's
figure, and is therefore relative. The second reference represents the range of
everyone's figures, and should therefore be absolute.
=IF(relative cell = MAX(absolute range), "Prize Winner", "")
In this example the IF statement for cell B2 will read:
=IF(C2=MAX($C$2:$C$6),"Prize Winner","Better luck next time")
When this is filled down through cells B3 and B4, the first reference to the
individual's sales figure changes, but the reference to all three sales figures
($C$2:$C$4) should remain constant. By doing this, you ensure that the IF
statement is always checking to see if the individual's figure is the biggest out
of the three.
A further possibility is to nest another IF statement to display a message if a
value is the minimum of a range. Beware of syntax here the formula could
become quite unwieldy!
AND, OR, NOT
Rather than create large and unwieldy formulae involving multiple IF
statements, the AND, OR and NOT functions can be used to group logical tests
or conditions together. These three functions can be used on their own, but in
that case they will only return the values TRUE or FALSE. As these two values
are not particularly meaningful on a spreadsheet, it is much more useful to
combine the AND, OR and NOT functions within an IF statement. This way, you
can ask for calculations to be performed or other text messages to appear as a
result.
AND
This function is a logical test to see if all conditions are true. If this is the case,
the value TRUE is returned. If any of the arguments in the AND statement are
found to be false, the whole statement produces the value FALSE. This function
is particularly useful as a check to make sure that all conditions you set are
met.
Arguments are entered in the AND statement in parentheses, separated by
commas, and there is a maximum of 30 arguments to one AND statement. The
following example checks that two cells, B1 and B2, are both greater than 100:
=AND(B1>100,B2>100)
If either one of these two cells contains a value less than a hundred, the result
of the AND statement is "FALSE". This can now be wrapped inside an IF
function to produce a more meaningful result. You may want to add the two
figures together if they are over 100, or display a message indicating that they
are not high enough.
NOT
NOT checks to see if the argument is false. If so, the value TRUE is returned. It
is best to use NOT as a provided this is not the case function. In other words, so
long as the argument is false, the overall statement is true. In the example
below, the cell contents of B1 is returned unless the number 13 is encountered.
If B1 is found to contain 13, the message "Unlucky!" is displayed:
=IF(NOT(B2=13),B2,"Unlucky!")
The NOT function can only contain one argument. If it is necessary to check
that more than one argument is false, the OR function should be used and the
true and false values of the IF statement reversed. Suppose, for example, a
check is done against the numbers 13 and 666:
=IF(OR(B2=13,B2=666),"Unlucky!",B2)
Financial functions
Excel offers many different financial functions. For a complete list use Excel
help (F1), browse the Table of Contents, select Working with Data, and
within the Function Reference section locate the Financial Functions sub-
menu. This course covers the following financial functions in more detail:
FV (Future Value), PV (Present Value), NPV (Net Present Value), RATE and PMT
(Payment)
Example 2:
You are thinking about starting a pension fund. You plan to deposit 2000 in the
fund at the beginning of each year and you expect the average rate of return to
be 9% per year for the entire term. Assuming you are now 30 years old, how
much money will your account accumulate by the time you are 65? Use the
formula =FV(9%,35,-2000, ,1). This informs you that your pension fund will be
worth 470,249.45 at the end of 35 years.
Now assume that you started the pension fund 3 years earlier and have already
accumulated 7500 in your account. Use the formula =FV(9%,35,-2000,-
7500,1) to find that your fund will grow to 623,354.20 at the end of the 35
years.
In both cases the type argument is 1 because the payments occur at the
beginning of the period.
Helpful hint:
Including this argument is particularly important in financial calculations that span many years. If you omit the
type argument in the formula, Excel assumes that you add money to your account at the end of each year and
would have returned the value 584,526.27 a difference of 38,828.
Present Value function (PV)
This function calculates the present value of an investment. The PV is the total
amount that a series of future payments is worth now. For example, when you
borrow money, the loan amount is the present value to the lender.
Present value is one of the most common methods for measuring the
attractiveness of a long-term investment. It is determined by discounting the
payments received from the investment back to the present time. If the present
value of the payments is greater than the cost of the investment, the
investment is a good one.
You can calculate the PV of a series of equal periodic payments or a lump sum.
This function takes the arguments (rate, number of periods, payment, future
value, type) as detailed below:
= PV(rate,nper,pmt,fv,type)
rate is the interest rate per period. For example, if you obtain an car loan at a
10 percent annual interest rate and make monthly payments, your
interest rate per month is 10%/12, or 0.83%. You would enter 10%/12, or
0.83%, or 0.0083, into the formula as the rate.
nper is the total number of payment periods in an annuity. E.g. if you get a
four-year car loan and make monthly payments, your loan has 4*12 (or
48) periods. You would enter 4*12 or 48 into the formula for nper.
pmt is the payment made each period and cannot change over the life of the
annuity. Typically, pmt includes principal and interest but no other fees or
taxes. For example, the monthly payments on a 10,000, four-year car
loan at 12 percent are 263.33. You would enter -263.33 into the formula
as the pmt. If pmt is omitted, you must include the fv argument.
fv is the future value, or a cash balance you want to attain after the last
payment is made. If fv is omitted, it is assumed to be 0 (the future value
of a loan, for example, is 0). For example, if you want to save 25,000 to
pay for a special project in 10 years, then 25,000 is the future value. You
could then make a conservative guess at an interest rate and determine
how much you must save each month. If fv is omitted, you must include
the pmt argument.
type is the number 0 or 1 and indicates when payments are due.
To calculate the PV of a series of payments, enter a value for the payment
argument. To calculate the PV of a lump sum payment, enter a value for the
future value argument. For an investment
with both a series payment and a lump-sum
payments, use both arguments.
Example 1:
To establish the Present Value of an investment
of 100 per month over 10 years at an annual
interest rate of 5%:
Example 2:
You are presented with an investment opportunity that returns 1000 each year
over the next five years. To receive this annuity, you must invest 4000. Are you
willing to pay 4000 today to earn 5000 over the next five years? To decide
whether this investment is acceptable, you need to determine the present value
of the 1000 per year payments you will receive.
As an alternative, you could invest your 4000 in an account that pays 4.5%
interest. Therefore, we will use the rate of 4.5% as the discount rate of your
investment. To determine the present value of this investment, we will use the
formula =PV(4.5%,5,1000), which returns the value -4389.98, meaning that
you should be willing to spend 4389.98 now to receive 5000 over the next 5
years. Because your investment is only 4000, you can see that this is an
acceptable investment.
If you were offered a lump sum of 5000 at the end on the 5 year period
instead of each year, would the investment still be attractive? To find out, use
the formula: =PV(4.5%, 5, , 5000) A comma is used as a placeholder for the
unused payment argument.
This formula returns the present value of -4012.26 which means that, at a
discount rate of 4.5%, you should be willing to spend 4012.26 to receive
5000 in five years time. Although this is not as attractive, it is still acceptable
because your investment is only 4000.
Net Present Value (NPV)
NPV calculates the Net Present Value of an investment by using a discount rate
and a series of future payments (negative values) and income (positive values).
The NPV function calculates the net present value, which is another common
method for determining the profitability of an investment. Any investment that
gives an NPV value greater than zero is considered profitable. This function
takes the arguments (rate, value1, value2 ) as detailed below:
= NPV(rate,value1,value2, ...)
rate is the rate of discount over the length of one period.
value1, value2, ... are 1 to 29 arguments representing the payments and
income.
value1, value2, ... must be equally spaced in time and occur at the end
of each period.
NPV uses the order of value1, value2, ... to interpret the order of cash
flows. Be sure to enter your payment and income values in the correct
sequence.
Arguments that are numbers, empty cells, logical values, or text
representations of numbers are counted; arguments that are error
values or text that cannot be translated into numbers are ignored.
If an argument is an array or reference, only numbers in that array or
reference are counted. Empty cells, logical values, text, or error values
in the array or reference are ignored.
Helpful hints:
NPV is similar to the PV function (present value). There are two main differences between PV and NPV.
1. PV allows cash flows to begin either at the end or at the beginning of the period but must be made
constantly throughout the investment, whereas NPV assumes that all payments and receipts are evenly
distributed and that they occur at the end of the period.
2. NPV allow variable cash flow values, whereas PV assumes constant inflow values.
NPV is also related to the IRR function (Internal Rate of Return). IRR is the rate for which NPV equals zero:
NPV(IRR(...), ...) = 0.
If the cost of the investment must be paid at the beginning of the period, you should not include the cost as
one of the functions value arguments, but should subtract it from the result of the function.
If, however, the cost must be paid at the end of the first period, you should include it as a negative first
value argument.
Example of NPV:
You are thinking about an investment on which you expect to incur a loss of
55.000 at the end of the first year, followed by gains of 95,000, 140,000,
and 185,000 at the end of the second, third, and fourth years. You will invest
250,000 up front, and the discount rate is 12%. To calculate this investment,
use the formulae:
=NPV(12%,-55000, 95000, 140000, 185000) -250000
The result of -6153.65 tells you that you will not make a profit from this
investment. (Note that the negative numbers in this formula show the money
you have spent on your investment.)
Helpful hint:
You can use the Excel Goal Seek command to determine what initial cost or interest rate would justify the
investment. This is covered on the Advanced Excel Data Analysis Tools course.)
If you paid the initial investment at the end of the first year, instead of at the
beginning, you would use the following formula:
=NPV(12%, (-250000-55000), 95000, 140000, 185000)
The result of 20,632.07 would suggest that this might be a profitable
investment.
RATE
The RATE function determines the rate of return of an investment that
generates a series of equal periodic payments or a single lump sum payment.
This function takes the argument (number of periods, payment, present value,
future value, type, guess) as detailed below:
= RATE(nper,pmt,pv,fv,type,guess)
nper is the total number of payment periods in an annuity.
pmt is the payment made each period and cannot change over the life of the
annuity. Typically, pmt includes principal and interest but no other fees or
taxes. If pmt is omitted, you must include the fv argument.
pv is the present value the total amount that a series of future payments is
worth now.
fv is the future value, or a cash balance you want to attain after the last
payment is made. If fv is omitted, it is assumed to be 0 (the future value
of a loan, for example, is 0).
type is the number 0 or 1 and indicates when payments are due.
guessis your guess for what the rate will be.
If you omit guess, it is assumed to be 10 percent.
If RATE does not converge, try different values for guess. RATE usually
converges if guess is between 0 and 1.
You use either the payment (pmt) argument to calculate the rate for a series
of equal periodic payments or the future value (fv) argument to calculate the
rate of a lump sum payment.
The RATE function uses an iterative process to calculate the rate of return. The
function begins by computing the net present value (npv) of the investment at
the guess rate. If that first npv is greater than zero, the function selects a
higher rate and repeats the npv calculation; if the first npv is less than zero, the
function selects a lower rate for the second iteration. RATE continues this
process until it arrives at the correct rate of return or until it has gone through
20 iterations.
Helpful hints:
Make sure that you are consistent about the units you use for specifying guess and nper. If you make monthly
payments on a four-year loan at 12 percent annual interest, use 12%/12 for guess and 4*12 for nper. If you
make annual payments on the same loan, use 12% for guess and 4 for nper.
RATE is calculated by iteration and can have zero or more solutions. If the successive results of RATE do not
converge to within 0.0000001 after 20 iterations, RATE returns the #NUM! error value. If this happens, try
entering a different guess rate and give the function another chance. A rate between 10% and 100% usually
works.
Example:
You are considering an investment that will pay you five annual 1000
payments. The investment costs 3000. To determine the actual annual rate of
return on your investment, use the formula:
=RATE(5, 1000, -3000)
This formula returns 20%, an excellent rate of return on this investment.
Payment function (PMT)
The payment function takes a loan amount, length of loan, and interest rate to
calculate the monthly repayments.
The format is =PMT(rate,nper,pv)
Rate is the interest rate per period.
nper is the total number of payments in the
period.
Pv is the present value (total size) of the
loan.
fv is the future value, or a cash balance
you want to attain after the last
payment is made.
type is the number 0 or 1 and indicates when payments are due.
Example 1:
A 10 year loan (120 months) of 40,000 at a rate of 6% would need monthly
repayments of 444.08. The amount in cell C5 is made negative because the
loan is decreasing.
The PMT function can also be used to calculate regular payment needed to save
towards a specific sum of money, in a known time period, e.g. money needed for
a holiday, or for school fees, etc.
Example 2:
You would like to purchase a new car in 12
months time, and estimate you will need
10,000 to do so. How much do you need to
save each month if you know the interest rate
for that period will be 5%?
This time you know the future value rather
than the present value. Notice there is an empty argument in the PV position
indicated by two commas.
You would need to save 814.41 per month.
Data tables
Data tables are part of a suite of commands sometimes called what-if analysis
tools. A data table is a range of cells that shows how changing certain values in
your formulae affects the results of the formulas. Data tables provide a shortcut
for calculating multiple versions in one operation and a way to view and
compare the results of all of the different variations together on your
worksheet.
For example, use a one-variable data table if you want to see how different
interest rates affect a monthly mortgage payment.
In the previous example the PMT function was used to calculate a single output
value (i.e. the monthly payment) based on three input values (i.e. the rate, the
term and the loan amount). Often in such calculations it is of interest to see
how the repayments would change over a range of input values.
Although it would be possible to change the interest rate (C3) manually, a data
table provides a much easier way to see what the repayments would be for
several different rates of interest (or any other input variable) at once.
Online learning
There is also a comprehensive range of online training available via
TheLearningZone at: www.ucl.ac.uk/elearning
Getting help
The following faculties have a dedicated Faculty Information Support Officer
(FISO) who works with faculty staff on one-to-one help as well as group
training, and general advice tailored to your subject discipline:
Arts and Humanities
The Bartlett
Engineering
Maths and Physical Sciences
Life Sciences
Social & Historical Sciences
See the faculty-based support section of the www.ucl.ac.uk/is/fiso Web page for more
details.
A Web search using a search engine such as Google (www.google.co.uk) can also
retrieve helpful Web pages. For example, a search for "Excel tutorial would
return a useful selection of tutorials.