formulas-functions-excel
formulas-functions-excel
with Excel
Kiruthika Ragupathi
Assistant Director
(Educational Technology)
Introduction ............................................................................................................... 4
Setting up Data........................................................................................................... 6
Inserting a new column or row .................................................................................................. 6
Formatting the worksheet ......................................................................................................... 6
Cutting up & Piecing together Text Strings using Text functions ................................ 18
More Information..................................................................................................... 28
Synopsis
Need to perform complex calculations and data analysis? The usage of formulas and functions is what
gives an Excel spreadsheet much of its power. This workshop explores the formula and functions that
are useful for computing and managing data. This course begins with mathematical principles and
moves on to basic formula construction. Participants will learn about mathematical functions, statistical
functions, conditional calculations, and lookup tables. In addition, the use of Analysis ToolPak will be
discussed aiding in the generation of descriptive statistics and regression.
Objectives
By the end of this workshop, participants should be able to:
Microsoft Excel has many capabilities that make it suitable for use as a data management tool. It
provides multiple features for organising and managing data, so you can ensure that data is entered
correctly and calculations and formulas are valid.
Validation features are very important for maintaining accurate records and to ensure that
• the data is correct,
• it is entered in the proper format, and
• formulas are working correctly,
Excel makes use of formulas (mathematical expressions that you create) and functions (mathematical
expressions that are already available in Excel) to dynamically calculate results from the data available
in your worksheets.
Let us start with an overview of the most important elements of the command area.
1. Use the File menu to open new or saved workbooks, save, print or close workbooks or manage
Excel options.
2. You can set up a custom Quick Access toolbar on the upper left corner of the screen. You can
place the most commonly used commands here.
3. The Ribbon is split into tabs where the commands are organised into logical groups. Each tab
corresponds to the various toolbars used in the previous versions of Excel.
4. An Excel-help function as a question-mark icon on the outer right of the Ribbon.
This section explains how to navigate a spreadsheet to edit and format cells. The concepts can easily be
applied to early versions of Excel; menu locations may differ but commands are the same. The core
document of Excel is a workbook. An Excel workbook can hold any number of sheets. Several
worksheets can be saved together to form a workbook. The main types of sheets are:
• Work sheets
• Chart sheets
At any one time, only one sheet is active in a workbook. Each spreadsheet is gridded into columns and
rows. Columns are denoted using letters, and rows are denoted by numbers. Cells are referenced by
their column and row. For example, the cell in the upper left hand corner of the spreadsheet is called
“A1,” for it is in column A and row 1.
4 Formulas and Functions with Excel
Kiruthika Ragupathi, email: [email protected]
Centre for Development of Teaching and Learning
Below is a picture of a blank workbook and descriptions of the more frequently used items.
File Menu
Open, start and Home Ribbon
Function Button
save workbooks Adjust appearance
Insert any of Excel’s
and data type
preset functions into cells
Formula Bar
This area allows you to
clearly edit individual cells
Selecting cells
Edit individual cells by clicking on them. Click a cell and drag the mouse pointer to select a range of cells.
You can also select entire rows and columns by clicking on the number or letter heading of that
alignment. To select non-adjacent cells, hold down the CTRL key, and then click the cells that you want.
To insert a new worksheet in front of an existing worksheet, select that worksheet and then, on the
Home tab, in the Cells group, click Insert, and then click Insert Sheet. You can also right-click the tab of
an existing worksheet, and then click Insert. On the General tab, click Worksheet, and then click OK.
Navigating
To change the active cell, use the arrow keys, Page Up or Page Down keys, or use the mouse to click a
new cell or drag the scroll bars.
Setting up Data
To use a spreadsheet efficiently, it helps to organise the data so that it is easy to read. When grading,
columns are typically used for each assessment item, whereas rows are used for the individuals. The
first row will be used for the column titles and the first column will be used for the serial number. You
can use the second row to indicate the maximum possible score for each of the assessment item.
You may also use the Insert button to add new columns found in the Home tab,
Cells group. When you insert a column or row, content found in columns will be
moved to the right, and content in rows will be moved down.
Appearance
Formatting the appearance of
cells, rows, and columns can be
done with buttons in the Home
ribbon or by right-clicking and
choosing options from Format
menu. To format cells, select
the Home ribbon then select
the column, row, group or the
cells that you want to format.
Then, select the formatting
options you desire.
Data Types
The data type manages how Excel will display and interpret data in the cells. For instance, you may
choose percentages as a fraction, decimal or whole number. It is important that excel interprets your
data correctly since Excel’s functions depend on the type of data being manipulated. After you type
numbers in a cell, you can change the format in which they are displayed.
Freeze Panes
This is used to keep titles in sight when you scroll down a page. To freeze panes, first “split” the
worksheet so that you can look at two areas independently.
On the View tab, in the Window group, select Split. A thick grey bar should appear on the sheet. To
make a split, drag the grey bar to a position next to or below the title row. When you have positioned
the bar where you would like it, select Freeze Panes from the Window group of the View tab. The thick
grey bar will be replaced by a thin black line and the row/column will stay in place.
Through this Speak Cells functionality, Excel can read back to you what you have typed while you check
that audio against your original data. For this to work, some commands have to be added to the quick
access toolbar.
• Using the Excel Options, and in the Customize section, choose All Commands.
• Then scroll down to select the Speak Cells command
• Click Add and click OK. And this option is now available for use in the Quick Access toolbar.
• Each time, you want to use a text-to-speech command, choose the icon , from the Quick
Access Toolbar.
+ for addition
- for subtraction
* for multiplication
/ for division
% for percentage
^ for exponentiation (power)
In addition you can use parentheses and decimal points, where needed.
Constructing a formula
• Excel requires that EVERY formula begin with an equal sign (=). If you just type without this symbol,
Excel treats the entry as text.
• To start entering a formula in a cell, click in that cell and then type the formula. Type Enter or Tab
to move to the next cell when you have finished entering the formula.
• Formulas containing numbers will produce results that will not change. e.g., the formula = 200*7
always produces the result 1400.
• However, a formula that contains cell references produces a result that may change depending on
the data in the cell. e.g., the formula = C2+D2 will produce a result based on the data in cells C2
and D2.
But sometimes, your formula will always have to point to exactly the same cell or cells, no matter
where you copy and paste your formula. This is known as absolute referencing and have an added
feature of a dollar sign $ placed in front of the row and column references. For example, if you wanted
to add cells A1 and B1 using an absolute reference, your formula would be = $A$1 + $B$1.
Numeric Precision
Excel maintains an internal numeric precision of 15 digits. Excel stores 15 digits internally, but rounds
the value for the screen display according to the format of the cell. When you apply a formula, Excel
looks at the actual value held in the cell, not the number displayed. This means that if you have
formatted a number to no decimal places and a whole number is displayed, the total will not
necessarily be the same as the sum of the resulting whole numbers as all the fractional parts will have
been added as well.
3. This subtracts the value in the cell B3 from the value in cell B2 and then multiplies the result by
the value in cell B4
= (B2-B3)*B4
4. This formula uses the SUM function to ass the values in the range C1:C12
= SUM(C1:C12)
5. This one compares the value in cell A1 and Value in cell B1. If the values in the two cells are
identical, then the formula returns TRUE otherwise, it returns FALSE.
= A2=B1
6. For example, to find the average of the values in the cells A2 to A10 you could do this several
ways:
= (A2 + A3 + A4 + A5)/4
= SUM (A2,A3,A4,A5)/4
= SUM (A2:A5)/4
= AVERAGE (A2,A3,A4,A5)
= AVERAGE (A2:A5)
These formulas would all give the same result if all the cells contained values but the easiest
one to type is probably the bottom one. It is also safer to use the AVERAGE function as that
calculates how many values there are in the range you select, using =SUM(A2:A5)/4 would lead
to an error if one of those cells was intentionally a blank row as you may only have 3 actual
values in that range.
Inserting a function
A function is a predefined/prewritten formula that takes a value or values, performs an operation on a
range of cells you select, and returns a value or values. Functions are used to simplify and shorten
formulas on a worksheet, especially those that perform lengthy or complex calculations. Excel refers to
each range of cells in the function as an argument. For complex calculations, it might be necessary to
use as many as 3 to 4 arguments.
1. Select the cell where you would like the average score to appear.
2. From the Formulas tab, choose Insert Function.
9. Under the Number1 type the range of cells that you want to use or you can also drag the
mouse to select the range of cells to be included as the function’s arguments and click Ok.
10. The formula result is displayed on the window for you as a preview.
2. Click on the drop-down arrow to the left of the formula bar to select the function you wish to
use.
3. Click on the More Functions... option at the bottom of the list to display a window showing all
the available functions.
4. When you have selected the function, the Insert Function dialog box opens to help you
complete the arguments after the function so that Excel calculates the right result.
5. When each function is selected a short description of the function and the type of arguments
to be used is displayed in the dialog box.
6. For a function like the SUMSQ function you need to select a range of cells (C2:F2 in this case) to
add together the sums of the squares of the arguments chosen.
In the Insert Function dialog box, you can choose All from the list or choose a specific category
of functions you are interested in that may contain the function and look for it in there.
Mathematical Calculations
Function What it Does
SUM Adds its arguments
SUMIF Adds the cells specified by one or many given criteria
SUMPRODUCT Returns the sums of the products of two arrays
SUBTOTAL Returns a subtotal of a filtered list or database
TRUNC Truncates a number to an integer
ROUND Rounds a number to a specified number of digits
ROUNDUP Rounds a number up, away from zero
INT Rounds a number down to the nearest integer
ABS Returns the absolute value of a number
MOD Returns the remainder from division
SQRT Returns a positive square root
POWER Returns the result of a number raised to a power
For example, if you would require a yearly summary report, you want to sum the values in cells B2 of
each of the monthly sheets. You have named your sheets "Jan" , "Feb", etc. Then to calculate, key in
the following formula:
=Jan!B2+Feb!B2+Mar!B2...+Dec!B2
You can also write this as follows:
=SUM(Jan:Dec!B2)
SUMIF
The general format for the SUMIF formula is as follows:
=SUMIF(range where the criteria is to be applied, criteria, sum what).
A B C D
1 Date Country Name Amount
2 05/01/2011 IN Lim 2
3 06/01/2011 SG Peter 6
4 07/01/2011 US Lim 8
5 05/01/2011 AU Peter 3
6 06/01/2011 DE Lim 4
7 07/01/2011 CN Peter 6
Example 1: Sum the values of the cells D2 to D7, only if they are greater than 5
=SUMIF(D2:D7,">5",D2:D7); Result should be 20.
Example 2: Sum the values of the cells D2 to D7 if the value in cells C2 to C7 is “Lim” or equivalent to
the value in cell C2.
=SUMIF(C2:C7,"Lim" ,D2:D7) ; Result should be 14.
or
=SUMIF(C2:C7,C2 ,D2:D7)
SUMPRODUCT
Let's say that you have a series of quantities in cells A1 to A5 and a series of unit prices in B1 to B5.
With SUMPRODUCT you can calculate total sales with this formula:
=SUMPRODUCT(A1:A5,B1:B5)
Basically SUMPRODUCT sums A1 multiplied by B1 plus A2 multiplied by B2 and so on. But you could
also apply specific conditions to it.
=SUMPRODUCT(A1:A5,B1:B5, (C1:C5="Lim")*1)
SUBTOTAL
When the Filter Data is used, then the SUBTOTAL function is a very useful and interesting function. The
function SUBTOTAL allows to count, to sum or to calculate the average of filtered elements of a
database.
TRUNC
The TRUNC function does the same as the INT or ROUNDDOWN functions. The TRUNC function
removes decimals without rounding. If you have 2.2 or 2.7 in cell A1 =TRUNC (A1,0) will return 2.
Interestingly enough if you have 12345 in B1 using a minus sign in the second argument of
TRUNC =TRUNC(B1,-3) will return (12,000). This is very useful when you don't want to show the
hundreds, the tens and units in a report.
ROUND
This function removes decimals rounding up the last decimal if the next one is 5 or over. So if you have
4.126 in cell A1 and use the formula =ROUND(A1,2) the result will be 4.13 if the value in A1 is 4.123
the result will be 4.12.
ABS
=ABS(A1) will return 5 if in cell A1 you have -5 or 5. This function removes the sign.
MOD
The modulo is the remainder left after a division.
=MOD(32,6)
is 2 because you have 5 times 6 in 30 and the remainder is 2.
There is no specific Excel function to extract the cubic root or any other root, but can be achieved by
using POWER function. You can raise a number to a power (multiplying it by itself a certain number of
times with this function. Hence:
=POWER(4,2) will result in 16 (4 times 4) or
=POWER(A1,2) will also result in 16 if the value in cell A1 is 4.
=POWER(A1,1/2) will give the square root of the value in cell A1
=POWER(A1,1/3) will give the cubic root of the value in cell A1
IF( ) function
The IF() function enables you to specify two different calculations based on a certain condition:
=IF(condition, calculation if condition is true, calculation if condition is false)
If the condition specified in the first argument is true, Excel performs the calculation specified in the
second argument, otherwise Excel calculates the third argument.
In the figure below, suppose you have an experimental test results that allows you to take a additional
value 4. Specifically, if the experimental value 3 is higher the additional value taken, then the adjusted
value will be the average of value 3 and the additional value 3. If the additional value is not higher than
the value 3, then their adjusted value score is their actual Test value 3. The IF( ) function below
performs this calculation to adjust the score for the cells in column F.
= IF(E2>D2, (D2+E2)/2, D2)or = IF(D2>E2, D2, (D2+E2)/2)
A B C D E F G
Additional Adjusted Final
1 Value 1 Value 2 Value 3
Value 3 Value Value
2 Iteration 1 88 73 82 80 82 81
3 Iteration 2 52 70 64 70 67 63
4 Iteration 3 87 73 82 80 82 81
5 Iteration 4 76 74 78 80 79 76
The first argument, E2>D2, tests whether the value 3 is better than the additional value 3. If the
condition is true, the second calculation is performed (the average of the two values, (E2+D2)/2). If the
condition is false, the adjusted value is simply the actual value 3, D2 in this case.
Note: ISBLANK( ) function tests whether a certain cell is blank. This function returns TRUE if the cell is
blank and FALSE if it’s not.
=IF(AND(D2>E2,NOT(ISBLANK(D2))),D2 , (D2+E2)/2)
The first argument of the IF( ) function is a AND( ) function that tests both conditions, Improvement
Test 3 is greater than Test 3 and Test 3 is not blank. If both conditions are true, then the second
calculation is performed, else the calculation in the third argument is performed.
Excel's VLOOKUP function, which stands for vertical lookup, is used to find specific information that has
been stored in a spreadsheet table. VLOOKUP is a function that is used in a worksheet to return a value
from a table (either in the same sheet, another sheet or another workbook) that is related to the value
you give it. Say you have a parts list in a table on one sheet containing thousands of parts numbers and
their related information. The table shows the part number in the first column, the part description in
the second column, the parts supplier in the third column, the parts price in the fourth column and so
on. On a separate sheet you have an invoice with columns for the Quantity, the Part number, the part
Description, the Price and the Total.
When you enter the part number in the Part number column of the Invoice, the VLOOKUP function is
used to get the details for Description column and the unit price column for the part number. Although
the IF( ) function can be very useful in these circumstances, it is limited to either TRUE or FALSE
outcomes. But in these types of examples with large inventories or contact list, we need a function that
can handle multiple outcomes. The VLOOKUP( ) function is ideally suited for this sort of calculation.
Here’s the syntax of a VLOOKUP Function:
=VLOOKUP($D19,PartsList!$A$1:$D$11,2,0)
The first argument, the lookup value, is the value you wish to look for in the lookup table which is the
part number in this example.
The lookup table range is the range on the worksheet that contains the lookup table. You can use a
reference to a range or a range name. The values in the first column of the table are the values
searched by lookup_value. These values can be text, numbers, or logical values.
Finally, the value column in argument 3 is to indicate which column of the table is to be used for the
actual result. Specify the value column by indicating what numeric column of the lookup table to use. In
the Parts-Description lookup table above, use column 2 if you want part description.
Range_lookup specifies whether you want VLOOKUP to find an exact match or an approximate match.
Note: The first column of a vertical lookup table must be in sorted order.
1. In the Lookup_value (first) argument box, select cell A4 (the value for which the calculation is
made).
2. Select the Table_array (second) argument box; use the separate table that has been created
earlier. In our example, the lookup table is in 'PartsList'!A2:D11. Look up table has been
created in the worksheet named “PartsList” and is in the columns A2 to D11. Now adjust the
formula such that the table array becomes an absolute reference, 'PartsList'!$A$2:$D$11.
3. In the Col_Index_num (third) argument box, type in the number of the column in the data
table. A Col_index_num of 1 returns the value in the 1st column in table_array; a
Col_index_num of 2 returns the value in the 2nd column in table_array and so on. In this
example, we are using the 2nd column, hence the value is 2
4. Range_lookup can be either a 0 or 1, else you could use TRUE or FALSE. By default, it is set as
TRUE. However, if an exact match is needed, choose 0 or FALSE.
Pivot Tables
The Pivot tables in Excel are very useful and powerful feature and can be used to summarize, analyse,
explore and present your data with ease.
When you create a PivotTable report from worksheet data, that data becomes the source data for the
PivotTable report.
1. Select the range of cells that contains the data along with column headings.
2. On the Insert tab, in the Tables group, click PivotTable.
3. The Create PivotTable dialog box is open.
4. Under Choose the data that you want to analyze, make sure that Select a table or range is
selected, and then in the Table/Range box, make sure the range of cells that you want to use is
listed.
5. Under Choose where you want the PivotTable report to be
placed, choose either the New Worksheet or Existing
Worksheet and click OK.
6. An empty PivotTable report is added on the specified
worksheet along with the PivotTable Field List from which you
can select the fields that you would like to add to create a
layout and customize the PivotTable report.
7. To place any field in the default area of the layout section,
select the check box next to the field name in the field section.
By default, nonnumeric fields are added to the Row Labels area,
numeric fields are added to the Values area, while date/time
hierarchies are added to the Column Labels area.
8. To place a field in a specific area of the layout section, you can
also right-click the field name in the field section, and then
select Add to Report Filter, Add to Column Label, Add to Row
Label, or Add to Values.
9. You could also drag a field to the area that you want by clicking
and holding the field name in the field section, and then
dragging it to an area in the layout section.
We will use the familiar example of a class grades to illustrate the use of some of the more basic Excel
functions, like AVERAGE( ), MODE( ) AND MAX( ). Assume a class’s grade distribution is as follows: 3, 0,
4, 4, 4, 2, 4, 1, 4, 0, 3, 3, 1, 1, 3, 4, 2, 4, 0, 3, 3, 1, 3. These grades are based on a 4-point scale with 4=A
and 0=F. Using the AVERAGE( ) function, we find the class's average (or arithmetic mean) grade is a
disappointing 2.48, or a mid-C. The syntax for this common function is =AVERAGE(number1,
number2, ...). However, we don't get a clear picture of the class’s performance by simply looking at its
average. We can further analyze the data using the MEDIAN( ) function. The median gives the middle
number in a set of numbers and its syntax is =MEDIAN(number1, number2,...). When the median grade
is calculated, it is 3.0, meaning that half of the grades are higher than 3.0, and half are lower. Therefore,
despite the low class average, more students scored 3's and 4's than 2's, 1's and 0's.
Additionally, we can also analyze the grade distribution by using the MODE( ) function. The mode gives
the most frequently occurring value of a set of numbers and its syntax is =MODE(number1,
As a matter of factsyou can also get the MIN and MAX values using these functions.
=LARGE(A1:A5,1), =SMALL(A1:A5,1)
If we consider the example of a car in motion that is coming to a stop and are required to determine its
acceleration and initial velocity. Then, we can determine the car's acceleration and its initial velocity
with the help of the SLOPE( ) and INTERCEPT( ) functions. Hence, the y-axis values represent the square
of the car's velocity and the x-axis values represent the car’s position or distance travelled. In order to
find the acceleration, we divide the slope by 2 and to find the initial velocity, we take the square root of
the y-intercept.
The CORREL( ) function can then be used to ensure that the data displays a linear trend. It is always a
good idea to plot the data as well as use these statistics functions because sometimes trends are not
obvious. Additionally, a plot of the data allows us to visualize the data and gross blunders and errant
data points are easily detected.
STDEV
For error analysis, we use the STDEV function. When we carry out a number of repetitive
measurements of one quantity, we find the average value. This does not however tell us anything of
the precision of our measurement. The standard deviation of the measured values will give a measure
of the precision. To quickly determine the standard deviation of any measurement, use Excel's built-in
STDEV( ) function.
=STDEV(A2:A6)
Statistical Analysis
Microsoft Excel has numerous Add-in features that support statistical analysis. Statistical data analysis
in Excel is not recommended for analysing datasets with a large sample size or a large number of
variables, performing advanced statistical analyses, or for projects in which a number of procedures
need to be performed. Excel is a useful tool for answering basic analysis. The primary reason to use
Excel for statistical data analysis is because it is so widely available.
There are a number of disadvantages worth considering before using Excel for statistical analysis:
• Missing values are handled inconsistently, and sometimes incorrectly.
• Data has to be organised differently according to the analysis you wish to perform.
• Most analyses can only be done on one column at a time. This makes it inconvenient to do the
same analysis on many columns.
• There is no log or record of how an analysis was accomplished.
• It also lacks many important features for advanced analyses.
Check to see if the Data Analysis command is available in the Analysis group on the Data tab. If the
Data Analysis menu is available, then it indicates that the Analysis ToolPak is already loaded.
2. In the Manage drop-down menu, select Excel Add-ins, and click Go.
3. In the Add-Ins available box, select the Analysis ToolPak check box, and then click OK.
5. A configuration progress screen for Microsoft Office appears and once completed, the Data
Analysis menu should appear on the Data menu in the Analysis group.
Descriptive Statistics
The quickest way to get mean and standard deviation for an entire group is by using the Descriptive
Statistics in the Data Analysis tools. This generates simple descriptive statistics like average, median,
and standard deviation for a collection of data. You can choose several adjacent columns for the Input
Range and each column is analysed separately. The labels in the first row are used to label the output,
and the empty cells are ignored. If there are more non-adjacent columns to be analysed, then one has
to repeat the process for each group of adjacent columns. The procedure is straightforward, can
manage many columns reasonably efficiently, and empty cells are treated properly. To generate these
statistics,
1. From the Data menu in the Analysis group, select Data Analysis.
Sample output from the Descriptive Statistics tool appears as shown in the table below.
Measured Values
Mean 343.491
Standard Error 0.666719
Median 344
Mode 344
Standard Deviation 2.981658
Sample Variance 8.890283
Kurtosis 1.775491
Skewness -1.22725
Range 12.17
Minimum 335.53
Maximum 347.7
Sum 6869.82
Count 20
Largest(1) 347.7
Smallest(1) 335.53
Confidence Level (95.0%) 1.395459
Note:
Skewness is a measure of symmetry, or more precisely, the lack of symmetry. A distribution, or data set, is symmetric if it
looks the same to the left and right of the center point. Kurtosis is a measure of whether the data are peaked or flat relative to
a normal distribution.
Excel Help
Excel has a Help system built into the software. You can click on at any time and browse through
the topics for your specific topic or can search for it using the search option. To get help with a specific
procedure, click on the Help on this function in the Dialog box for the procedure you would like to run.
Office online
Microsoft also offers a very comprehensive online help at the Microsoft office - Help for Excel
2007, http://office.microsoft.com/en-
us/excel/FX100646951033.aspx?CTT=96&Origin=CL100570551033