and Functions
with Excel
KiruthikaRagupathi
PrincipalEducationalTechnologist
CentreforDevelopmentofTeachingandLearning(CDTL)
NationalUniversityofSingapore
email:kiruthika@nus.edu.sg
TABLE OF CONTENTS
Introduction................................................................................................................4
ExploringtheExcelWorkspace....................................................................................4
NavigatingtheWorkbook............................................................................................4
SettingupData............................................................................................................6
Insertinganewcolumnorrow..................................................................................................6
Formattingtheworksheet.........................................................................................................6
VerifyingData..............................................................................................................7
FormulasandFunctions...............................................................................................8
Constructingaformula..............................................................................................................8
Insertingafunction..................................................................................................................10
BuiltinFunctions.....................................................................................................................11
MathematicalCalculations........................................................................................13
ConditionalCalculations............................................................................................16
Cuttingup&PiecingtogetherTextStringsusingTextfunctions................................17
UsingLookuptables/References.............................................................................18
PivotTables...............................................................................................................20
CreateaPivotTablefromworksheetdata...............................................................................20
Statisticalfunctions...................................................................................................21
BasicStatisticalbuiltinfunctions............................................................................................21
Linearregressionfunctions......................................................................................................23
StatisticalAnalysis.....................................................................................................24
UsingtheAnalysisToolPak......................................................................................................24
DescriptiveStatistics................................................................................................................25
MoreInformation......................................................................................................27
Synopsis
Needtoperformcomplexcalculationsanddataanalysis?Theusageofformulasandfunctionsiswhat
givesanExcelspreadsheetmuchofitspower.Thisworkshopexplorestheformulaandfunctionsthat
are useful for computing and managing data. This course begins with mathematical principles and
movesontobasicformulaconstruction.Participantswilllearnaboutmathematicalfunctions,statistical
functions,conditionalcalculations, andlookuptables.In addition,theuseofAnalysisToolPakwillbe
discussedaidinginthegenerationofdescriptivestatisticsandregression.
Objectives
Bytheendofthisworkshop,participantsshouldbeableto:
Setupandverifydata
UnderstandthemathematicalorderofoperationsusedbyExcel
Usetheappropriatetypeofcellreference
Constructbasicformulas
Usestatisticalfunctions
Performconditionalcalculations
UseAnalysisToolpak
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
Introduction
Microsoft Excel has many capabilities that make it suitable for use as a data management tool. It
provides multiplefeaturesfor organising andmanaging data, so youcan ensurethat data isentered
correctlyandcalculationsandformulasarevalid.
Dataorganisationfeaturesenableyouto:
sortandfilterdata,
summariseandgroupdata,and
outlinedatasothatyoucanfocusonthekeypartsofyourdata.
Validationfeaturesareveryimportantformaintainingaccuraterecordsandtoensurethat
thedataiscorrect,
itisenteredintheproperformat,and
formulasareworkingcorrectly,
Excelmakesuseofformulas(mathematicalexpressionsthatyoucreate)andfunctions(mathematical
expressionsthatarealreadyavailableinExcel)todynamicallycalculateresultsfromthedataavailable
inyourworksheets.
ExploringtheExcelWorkspace
Letusstartwithanoverviewofthemostimportantelementsofthecommandarea.
1. Use the Office Button to open new or saved workbooks, save, print or close workbooks or
manageExceloptions.
2. YoucansetupacustomQuickAccesstoolbarontheupperleftcornerofthescreen.Youcan
placethemostcommonlyusedcommandshere.
3. TheRibbonissplitintotabswherethecommandsareorganisedintologicalgroups.Eachtab
correspondstothevarioustoolbarsusedinthepreviousversionsofExcel.
4. AnExcelhelpfunctionasaquestionmarkiconontheouterrightoftheRibbon.
NavigatingtheWorkbook
Thissectionexplainshowtonavigateaspreadsheettoeditandformatcells.Theconceptscaneasilybe
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
worksheetscanbesavedtogethertoformaworkbook.Themaintypesofsheetsare:
Worksheets
Chartsheets
Atanyonetime,onlyonesheetisactiveinaworkbook.Eachspreadsheetisgriddedintocolumnsand
rows.Columnsaredenotedusingletters,androwsaredenotedbynumbers.Cellsarereferencedby
theircolumnandrow.Forexample,thecellintheupperlefthandcornerofthespreadsheetiscalled
A1,foritisincolumnAandrow1.
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
Belowisapictureofablankworkbookanddescriptionsofthemorefrequentlyuseditems.
Creatinganewworkbook
StartanewworkbookbyclickingtheOfficeButtonandselectingNew.IntheNewWorkbookwindow,
clickBlankworkbook.WhenyoustartExcel,ablankworksheetopens.
Selectingcells
Editindividualcellsbyclickingonthem.Clickacellanddragthemousepointertoselectarangeofcells.
You can also select entire rows and columns by clicking on the number or letter heading of that
alignment.Toselectnonadjacentcells,holddowntheCTRLkey,andthenclickthecellsthatyouwant.
Addingdatamanually
To enter data manually into the spreadsheet, double click on the cell you want to edit. Notice that
whateveryoutypeappearsinboththecellandthecelleditoratthetop.Whenyouarefinishedtyping,
pressEnter.
Addinganewworksheet
ClicktheInsertWorksheettabatthebottomofthescreen.
InsertWorksheet
Renamingtheworksheet
DoubleclicktheNametab;whenthedefaultnameisselected,typethenewname.Youcanalsoright
clickontheNameTabandchooseRenametotypeinthenewname.Eachworksheetcanbecolour
coded,assettingdifferentcolorsishelpfulwhenyouhavealargenumberofworksheetsinaworkbook.
TosetthecoloroftheWorksheettabs,rightclickonthetabandselectanewcolor.
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
Navigating
Tochangetheactivecell,usethearrowkeys,PageUporPageDownkeys,orusethemousetoclicka
newcellordragthescrollbars.
Embeddingchartsandpictures
TocreateanewchartinExcel,ontheInsertmenu,fromtheChartsgroup,choosethecharttypeyou
prefer.Toinsertanotherfile,suchasaclipart,pictureorascannedimage,fromtheInserttab,under
theIllustrationsgroup,choosePictureorClipart.
SettingupData
Touseaspreadsheetefficiently,ithelpstoorganisethedatasothatitiseasytoread.Whengrading,
columnsaretypicallyusedforeachassessment item,whereasrowsareusedfortheindividuals.The
firstrowwillbeusedforthecolumntitlesandthefirstcolumnwillbeusedfortheserialnumber.You
canusethesecondrowtoindicatethemaximumpossiblescoreforeachoftheassessmentitem.
Insertinganewcolumnorrow
Theprocessforinsertingrowsandcolumnsissimilar.Toinsertacolumn,clicktheheaderwhereyou
want to add a new column or row. On the header, rightclick and in the dropdown context menu,
selectInsert.
YoumayalsousetheInsertbuttontoaddnewcolumnsfoundintheHometab,
Cellsgroup.Whenyouinsertacolumnorrow,contentfoundincolumnswillbe
movedtotheright,andcontentinrowswillbemoveddown.
Formattingtheworksheet
Theformattingofacellreferstoboththewayitisstyled(stylisticformatting)andthewayitfunctions
(numeric formatting). Formatting includes display characteristics such as font, size, alignment, style,
color,aswellasthetypeofdatathatthecellcontains.Forinstance,acellcanbeformattedtotreat
any data entered as a monetary amount and display only whole dollar amounts. Stylistic formatting
optionsmakeyourworksheetmoreattractiveandeasiertoread.
Appearance
Formatting the appearance
of cells, rows, and columns
can be done with buttons in
theHomeribbonorbyright
clickingandchoosingoptions
from Format menu. To
formatcells,selecttheHome
ribbon then select the
column, row, group or the
cellsthatyouwanttoformat.
Then, select the formatting
optionsyoudesire.
AnewformattingconceptcalledthedocumentthemeshasbeenintroducedinExcel2007andcanbe
foundinthePageLayoutTab.Theseallowyoutosetmanyformattingoptionsatonce.
DataTypes
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
The data type manages how Excel will display and interpret data in the cells. For instance, you may
choosepercentagesasafraction,decimalorwholenumber.Itisimportantthatexcelinterpretsyour
data correctly since Excels functions depend on the type of data being manipulated. After you type
numbersinacell,youcanchangetheformatinwhichtheyaredisplayed.
Themostcommonlyuseddatatypesforstudentdata
managementinExcelare:
Number: cells that contain only numerals, commas,
and decimal points that can be used in numerical
calculations.
FreezePanes
This is used to keep titles in sight when you scroll down a page. To freeze panes, first split the
worksheetsothatyoucanlookattwoareasindependently.
OntheViewtab,intheWindowgroup,selectSplit.Athickgreybarshouldappearonthesheet.To
makeasplit,dragthegreybartoapositionnexttoorbelowthetitlerow.Whenyouhavepositioned
thebarwhereyouwouldlikeit,selectFreezePanesfromtheWindowgroupoftheViewtab.Thethick
greybarwillbereplacedbyathinblacklineandtherow/columnwillstayinplace.
VerifyingData
Whenitisnecessarytoenterlargeamountsofdata,itisgoodpracticetohavethedatacheckedfor
accuracy.Thiscanbedoneimmediatelybythepersonenteringthedata,orentriescanbeverifiedbya
differentperson.Wouldntitbeconvenienttohaveatoolthatcouldprovideimmediatefeedbackof
thedataentered?
TexttoSpeechfeature
Excelprovidessuchatoolthatenablesaquickandeasydoublecheckofentriesbeforeyoucontinue
workingwiththedata.ItistheTexttoSpeechfeature.
ThroughthisSpeakCellsfunctionality,Excelcanreadbacktoyouwhatyouhavetypedwhileyoucheck
thataudioagainstyouroriginaldata.Forthistowork,somecommandshavetobeaddedtothequick
accesstoolbar.
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
UsingtheExcelOptions,andintheCustomizesection,chooseAllCommands.
ThenscrolldowntoselecttheSpeakCellscommand
ClickAddandclickOK.AndthisoptionisnowavailableforuseintheQuickAccesstoolbar.
Each time, you want to use a texttospeech command, choose the icon
AccessToolbar.
FormulasandFunctions
FormulasaretherealpowerofanExcelspreadsheet.Aformulausesstandardmathematicalsymbols
tooperateoncelladdressesand/ornumbers.Aformulacanbeacombinationofvalues(numbersor
cell references) and mathematical operators into an algebraic expression. Mathematical operators
includethefollowingsymbols:
+
foraddition
forsubtraction
* formultiplication
/ fordivision
% forpercentage
^ forexponentiation(power)
Inadditionyoucanuseparenthesesanddecimalpoints,whereneeded.
Constructingaformula
ExcelrequiresthatEVERYformulabeginwithanequalsign(=).Ifyoujusttypewithoutthissymbol,
Exceltreatstheentryastext.
Tostartenteringaformulainacell,clickinthatcellandthentypetheformula.TypeEnterorTab
tomovetothenextcellwhenyouhavefinishedenteringtheformula.
Formulascontainingnumberswillproduceresultsthatwillnotchange.e.g.,theformula=200*7
alwaysproducestheresult1400.
However,aformulathatcontainscellreferencesproducesaresultthatmaychangedependingon
thedatainthecell.e.g.,theformula= C2+D2willproducearesultbasedonthedataincellsC2
andD2.
Toviewtheformulasthatarecontainedinyourworksheet,pressCTRLand`(theapostrophekey)
together.Repeattohidetheformulasandshowthevalues.
All formulas follow the standard mathematical order of operations when calculating the results.
e.g.,theformula= A2 + B2 * C2willadddataincellA2withthemultipliedproductofB2and
C2.
Ifapartoftheformulaisinparenthesis,thenthatpartwillbecalculatedfirst.
Afterexpressionsintheparentheses,ExcelwillcalculateyourformulausingtheMathoperatorsin
thefollowingorder:Multiplication,Division,AdditionandSubtraction.
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
Copyformulasintoadditionalcells
Youcancopyformulasintoadditionalcellsbyselectingtheformula,andthenpasteintothedesired
cell. Usually, cells referenced in a formula are based on their relative location to the cell with the
formula(knownasrelativereferencing).Thecellreferenceswillchangedependingonwhereyoucopy
it.IfcellG2containstheformula=C2+D2,andyoucopythistoG3,theresultingformulawillbe=C3+D3.
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
featureofadollarsign$placedinfrontoftherowandcolumnreferences.Forexample,ifyouwanted
toaddcellsA1andB1usinganabsolutereference,yourformulawouldbe= $A$1 + $B$1.
Repeatthecalculationforeverycellinacolumn
To do this select the cell with the formula and when you move the pointer to the lower right hand
cornerofthecell,thecursorchangestoaboldplus(+)sign.Clickandholddownthemousewhileyou
dragtohighlightcellsdownthecolumntothelastrowofdata.Everyhighlightedcellnowcontainsthe
formula. Note: Display of #NA indicates problem(s) with the formula or the result is larger than the
widthofcell.
Roundvaluestoremovedecimalplaces
To reduce decimal places click on the Decrease Decimal button. Each click of this
button shrinks the result one decimal place. Be cautious with this tool though as
numberswillberounded.So,forinstance,an85.55willberoundedto86.
NumericPrecision
Excelmaintainsaninternalnumericprecisionof15digits.Excelstores15digitsinternally,butrounds
thevalueforthescreendisplayaccordingtotheformatofthecell.Whenyouapplyaformula,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
necessarilybethesameasthesumoftheresultingwholenumbersasallthefractionalpartswillhave
beenaddedaswell.
SampleFormulas
Formulascanbeacombinationofbuiltinfunctionsandyourownformulas.Letustakealookatsome
sampleformulas.
1. Thisformulamultiplies200x7,returning1400andonlyusesliteralvalues:
= 200*7
2. ThisaddsthevaluesincellsB2andC2:
= B2+C2
3. ThissubtractsthevalueinthecellB3fromthevalueincellB2andthenmultipliestheresultby
thevalueincellB4
= (B2-B3)*B4
4. ThisformulausestheSUMfunctiontoassthevaluesintherangeC1:C12
= SUM(C1:C12)
5. ThisonecomparesthevalueincellA1andValueincellB1.Ifthevaluesinthetwocellsare
identical,thentheformulareturnsTRUEotherwise,itreturnsFALSE.
= A2=B1
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
6. Forexample,tofindtheaverageofthevaluesinthecellsA2toA10youcoulddothisseveral
ways:
= (A2 + A3 + A4 + A5)/4
= SUM (A2,A3,A4,A5)/4
= SUM (A2:A5)/4
= AVERAGE (A2,A3,A4,A5)
= AVERAGE (A2:A5)
Theseformulaswouldallgivethesameresultifallthecellscontainedvaluesbuttheeasiest
onetotype isprobablythebottomone. It isalsosafertousetheAVERAGEfunction asthat
calculateshowmanyvaluesthereareintherangeyouselect,using=SUM(A2:A5)/4wouldlead
toanerror ifoneofthosecellswas intentionally ablankrow asyoumay onlyhave3actual
valuesinthatrange.
Insertingafunction
Afunctionisapredefined/prewrittenformulathattakesavalueorvalues,performsanoperationona
range of cells you select, and returns a value or values. Functions are used to simplify and shorten
formulasonaworksheet,especiallythosethatperformlengthyorcomplexcalculations.Excelrefersto
eachrangeofcellsinthefunctionasanargument.Forcomplexcalculations,itmightbenecessaryto
useasmanyas3to4arguments.
1. Selectthecellwhereyouwouldliketheaveragescoretoappear.
2. FromtheFormulastab,chooseInsertFunction.
3. Or,youcouldalsoclickontheFunction
button,
found just before the
formulabartouseanyofExcelspreset
functions.
4. TheInsertFunctiondialogboxappears.
5. Under Select a function, choose from
therangeoffunctionsavailable.
6. For example, choose the SUM function
andclickOK.
10
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
7. TheFunctionArgumentsdialogboxasshownbelowappears.
8. ForexampleletusconsidertheSUMfunctionthataddsallthenumbersinarangeofcells.
9. Under the Number1 type the range of cells that you want to use or you can also drag the
mousetoselecttherangeofcellstobeincludedasthefunctionsargumentsandclickOk.
10. Theformularesultisdisplayedonthewindowforyouasapreview.
BuiltinFunctions
Excelhasavarietyofbuiltinfunctionsthatcanbeaccessedusing
theFormulaWizard.
1. Clickinthecellwhereyouwanttheresultoftheformula
tobeplaced.Nowclickonthe=signintheformulabar.
2. Clickonthedropdownarrowtotheleftoftheformula
bartoselectthefunctionyouwishtouse.
3. ClickontheMoreFunctions...optionatthebottomof
thelisttodisplayawindowshowingallthe
availablefunctions.
4. Whenyouhaveselectedthefunction,the
InsertFunctiondialogboxopenstohelp
youcompletetheargumentsafterthe
functionsothatExcelcalculatestheright
result.
5. Wheneachfunctionisselectedashort
descriptionofthefunctionandthetypeof
argumentstobeusedisdisplayedinthe
dialogbox.
6. ForafunctionliketheSUMSQfunctionyou
needtoselectarangeofcells(C2:F2inthis
case)toaddtogetherthesumsofthe
squaresoftheargumentschosen.
11
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
7. Anexampleoftheresultofbycomputingtheformulaisshownatthebottomofthedialogbox.
Then,clicktheOKbuttonwhenyouaresatisfiedwiththeoutput.
8. Theresultwillnowbedisplayedontheselectedcellofyourspreadsheet.Ifyouclickonthe
cellcontainingtheresult,theformulausedwillbedisplayedintheformulabar.
IntheInsertFunctiondialogbox,youcanchooseAllfromthelistorchooseaspecificcategory
offunctionsyouareinterestedinthatmaycontainthefunctionandlookforitinthere.
12
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
Builtinfunctionscanbecategorisedasfollows:
FunctionCategory
Whatitdoes
mathfunctions.
Logical
ConsideraconditionandreturnTrueorFalse
Text
Manipulateorcreatestrings
Lookup/Reference
Manipulateorexamineareasofaworksheet
Statistical
Database
Date/Time
Engineering
Performcommonlyusedengineeringcalculations,manyof
which relate to Bessel Functions, Complex Numbers or
convertingbetweendifferentbases
Financial
Information
Usedtogetinformationaboutthecontentsofacell
MathematicalCalculations
Function
WhatitDoes
SUM
Addsitsarguments
SUMIF
Addsthecellsspecifiedbyoneormanygivencriteria
SUMPRODUCT
Returnsthesumsoftheproductsoftwoarrays
SUBTOTAL
Returnsasubtotalofafilteredlistordatabase
TRUNC
Truncatesanumbertoaninteger
ROUND
Roundsanumbertoaspecifiednumberofdigits
ROUNDUP
Roundsanumberup,awayfromzero
INT
Roundsanumberdowntothenearestinteger
ABS
Returnstheabsolutevalueofanumber
MOD
Returnstheremainderfromdivision
SQRT
Returnsapositivesquareroot
POWER
Returnstheresultofanumberraisedtoapower
13
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
SUM
=SUM(A1,B6,G6)
willreturnthesumofthevaluesincellsA1,B6andG6
=SUM(A1:A23)
willreturnthesumofthevaluesincellsA1toA23
=SUM(A1:A23,F3:F34) willreturnthesumofthevaluesincellsA1toA23plusthesumof
thevaluesincellsF3toF34
Forexample,ifyouwouldrequireayearlysummaryreport,youwanttosumthevaluesincellsB2of
eachofthemonthlysheets.Youhavenamedyoursheets"Jan","Feb",etc.Thentocalculate,keyin
thefollowingformula:
=Jan!B2+Feb!B2+Mar!B2...+Dec!B2
Youcanalsowritethisasfollows:
=SUM(Jan:Dec!B2)
SUMIF
ThegeneralformatfortheSUMIFformulaisasfollows:
=SUMIF(rangewherethecriteriaistobeapplied,criteria,sumwhat).
Date
Country
Name
Amount
05/01/2011
IN
Lim
06/01/2011
SG
Peter
07/01/2011
US
Lim
05/01/2011
AU
Peter
06/01/2011
DE
Lim
07/01/2011
CN
Peter
Example1:SumthevaluesofthecellsD2toD7,onlyiftheyaregreaterthan5
=SUMIF(D2:D7,">5",D2:D7);Resultshouldbe20.
Example2:SumthevaluesofthecellsD2toD7ifthevalueincellsC2toC7isLimorequivalentto
thevalueincellC2.
=SUMIF(C2:C7,"Lim" ,D2:D7);Resultshouldbe14.
or
=SUMIF(C2:C7,C2 ,D2:D7)
SUMPRODUCT
Let'ssaythatyouhaveaseriesofquantitiesincellsA1toA5andaseriesofunitpricesinB1toB5.
WithSUMPRODUCTyoucancalculatetotalsaleswiththisformula:
=SUMPRODUCT(A1:A5,B1:B5)
BasicallySUMPRODUCT sumsA1 multiplied by B1 plusA2 multipliedbyB2andso on. Butyoucould
alsoapplyspecificconditionstoit.
=SUMPRODUCT(A1:A5,B1:B5, (C1:C5="Lim")*1)
SUBTOTAL
WhentheFilterDataisused,thentheSUBTOTALfunctionisaveryusefulandinterestingfunction.The
function SUBTOTAL allows to count, to sum or to calculate the average of filtered elements of a
database.
14
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
Thefunctionrequirestwoarguments:
the first is a number between 1 and 11 that specifies the operation to be executed: 1(for
AVERAGE); 2(for COUNT); 3(for COUNTA); 4(for MAX); 5(for MIN); 6(for PRODUCT); 7(for
STDEV);8(forSTDEVP);9(forSUM);10(forVAR);11(forVARP).
thesecondistherangecoveredbythefunctionand
Hence,ifyouwantthesumofB2:45,thenusethefollowing:
=SUBTOTAL(9,B2:B45)
Roundingupthedecimals
Whenyou specify inthe format of a cell thatyou wantonly 2 decimals Excel showsonly 2 decimals
(roundingup)BUTyoushouldnotethatstillusesallthedecimals.Forexample,ifincellA1youentered
2.1456andusea2decimalformat,youwillsee2.15.NowifincellB1youwritetheformula=A1and
make the format "General" you will see still see 2.1456. Hence, functions like INT, TRUNC, ROUND,
ROUNDUPandROUNDDOWNwillenableyoutouseaspecificnumberofdecimalsinyourcalculations.
TRUNC
The TRUNC function does the same as the INT or ROUNDDOWN functions. The TRUNC function
removesdecimalswithoutrounding.Ifyouhave2.2or2.7incellA1=TRUNC (A1,0)willreturn2.
Interestingly enough if you have 12345 in B1 using a minus sign in the second argument of TRUNC
=TRUNC(B1,-3)willreturn(12,000).Thisisveryusefulwhenyoudon'twanttoshowthehundreds,
thetensandunitsinareport.
ROUND
Thisfunctionremovesdecimalsroundingupthelastdecimalifthenextoneis5orover.Soifyouhave
4.126incellA1andusetheformula=ROUND(A1,2) theresultwillbe4.13ifthevalueinA1is4.123
theresultwillbe4.12.
ABS
=ABS(A1)willreturn5ifincellA1youhave5or5.Thisfunctionremovesthesign.
MOD
Themoduloistheremainderleftafteradivision.
=MOD(32,6)
is2becauseyouhave5times6in30andtheremainderis2.
SQRTandPOWER
Toextractthesquarerootofanumberyouwilluseaformulalike:
=SQRT(16)thatwillresultin4because4multipliedby4is16or
=SQRT(A1) thatwillalsoresultin4ifthevalueincellA1is16.
ThereisnospecificExcelfunctiontoextractthecubicrootoranyotherroot,butcanbeachievedby
usingPOWERfunction.Youcanraiseanumbertoapower(multiplyingitbyitselfacertainnumberof
timeswiththisfunction.Hence:
=POWER(4,2)willresultin16(4times4)or
=POWER(A1,2)willalsoresultin16ifthevalueincellA1is4.
=POWER(A1,1/2)willgivethesquarerootofthevalueincellA1
=POWER(A1,1/3)willgivethecubicrootofthevalueincellA1
15
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
ConditionalCalculations
Excel has several logical functions that allow you to test cells and perform different operations
dependingontheircontents.
IF()function
TheIF()functionenablesyoutospecifytwodifferentcalculationsbasedonacertaincondition:
=IF(condition,calculationifconditionistrue,calculationifconditionisfalse)
Iftheconditionspecifiedinthefirstargumentistrue,Excelperformsthecalculationspecifiedinthe
secondargument,otherwiseExcelcalculatesthethirdargument.
Inthefigurebelow,supposeyouhaveanexperimentaltestresultsthatallowsyoutotakeaadditional
value4.Specifically,iftheexperimentalvalue3ishighertheadditionalvaluetaken,thentheadjusted
valuewillbetheaverageofvalue3andtheadditionalvalue3.Iftheadditionalvalueisnothigherthan
the value 3, then their adjusted value score is their actual Test value 3. The IF( ) function below
performsthiscalculationtoadjustthescoreforthecellsincolumnF.
= IF(E2>D2, (D2+E2)/2, D2)or= IF(D2>E2, D2, (D2+E2)/2)
Value1
Value2
Value3
2 Iteration1
88
73
82
80
82
81
3 Iteration2
52
70
64
70
67
63
4 Iteration3
87
73
82
80
82
81
5 Iteration4
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
conditionistrue,thesecondcalculationisperformed(theaverageofthetwovalues,(E2+D2)/2).Ifthe
conditionisfalse,theadjustedvalueissimplytheactualvalue3,D2inthiscase.
AND()andOR()functions
TospecifymultipleconditionswithinanIF()function,useExcel'sAND()andOR()functions.
=AND(condition1,condition2,...conditionn)
=OR(condition1,condition2,...conditionn)
AND( ) returns the value of TRUE if all its conditions are true, and returns FALSE otherwise. OR( )
returnsTRUEifatleastoneofthespecifiedconditionsistrue.
Note:ISBLANK()functiontestswhetheracertaincellisblank.ThisfunctionreturnsTRUEifthecellis
blankandFALSEifitsnot.
16
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
Themodifiedformulawouldthenbe:
=IF(AND(D2>E2,NOT(ISBLANK(D2))),D2 , (D2+E2)/2)
Cuttingup&PiecingtogetherTextStringsusingTextfunctions
Function
CONCATENATE
LEFT
MID
RIGHT
REPT
LEN
EXACT
MATCH
WhatitDoes
Joinstogethertwoormoretextstrings
=CONCATENATE(A2,B2)
Returnsaspecifiednumberofcharactersfromthestart
ofasuppliedtextstring
=LEFT(C2,8)
Returnsaspecifiednumberofcharactersfromthemiddle
ofasuppliedtextstring
=MID(A2,2,2)
Returnsaspecifiednumberofcharactersfromtheendof
asuppliedtextstring
=RIGHT(A2,3)
Returnsastringconsistingofasuppliedtextstring,
repeatedaspecifiednumberoftimes
=REPT(A2,3)
Returnsthelengthofasuppliedtextstring
=LEN(A2)
Testsiftwosuppliedtextstringsareexactlythesameand
ifso,returnsTRUE;Otherwise,returnsFALSE.
=EXACT(A2,F2)
Returnstherelativepositionofaniteminanarraythat
matchesthespecifiedvalueinaspecifiedorder.
=MATCH(D2,$D$2:D2,0)
17
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
UsingLookuptables/References
Excel'sVLOOKUPfunction,whichstandsforverticallookup,isusedtofindspecificinformationthathas
beenstoredinaspreadsheettable.VLOOKUPisafunctionthatisusedinaworksheettoreturnavalue
fromatable(eitherinthesamesheet,anothersheetoranotherworkbook)thatisrelatedtothevalue
yougiveit.Sayyouhaveapartslistinatableononesheetcontainingthousandsofpartsnumbersand
theirrelatedinformation.Thetableshowsthepartnumberinthefirstcolumn,thepartdescriptionin
thesecondcolumn,thepartssupplierinthethirdcolumn,thepartspriceinthefourthcolumnandso
on.OnaseparatesheetyouhaveaninvoicewithcolumnsfortheQuantity,thePartnumber,thepart
Description,thePriceandtheTotal.
WhenyouenterthepartnumberinthePartnumbercolumnoftheInvoice,theVLOOKUPfunctionis
usedtogetthedetailsforDescriptioncolumnandtheunitpricecolumnforthepartnumber.Although
the IF( ) function can be very useful in these circumstances, it is limited to either TRUE or FALSE
outcomes.Butinthesetypesofexampleswithlargeinventoriesorcontactlist,weneedafunctionthat
can handle multiple outcomes. The VLOOKUP( ) function is ideally suited for this sort of calculation.
HeresthesyntaxofaVLOOKUPFunction:
=VLOOKUP(lookupvalue,lookuptablerange,valuecolumn)
PartNumber Description
Suppliers
Price
D001
Nut
A1tradersPteltd
$2.00
D002
Bearing
XYZDealers
$4.00
D003
Bolt
UniversalPartsDistributors
$1.50
D004
MotorPulley
SamMotorsandsuppliers
$15.00
D005
Gear
AmroPartsco.Ltd
S70.00
Inthissample,theformulais
=VLOOKUP($D19,PartsList!$A$1:$D$11,2,0)
Thefirstargument,thelookupvalue,isthevalueyouwishtolookforinthelookuptablewhichisthe
partnumberinthisexample.
Thelookup table rangeistherangeontheworksheetthatcontainsthelookuptable.Youcanusea
reference to a range or a range name. The values in the first column of the table are the values
searchedbylookup_value.Thesevaluescanbetext,numbers,orlogicalvalues.
Finally,thevaluecolumninargument3istoindicatewhichcolumnofthetableistobeusedforthe
actualresult.Specifythevaluecolumnbyindicatingwhatnumericcolumnofthelookuptabletouse.In
thePartsDescriptionlookuptableabove,usecolumn2ifyouwantpartdescription.
Range_lookupspecifieswhetheryouwantVLOOKUPtofindanexactmatchoranapproximatematch.
Note:Thefirstcolumnofaverticallookuptablemustbeinsortedorder.
18
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
1. IntheLookup_value(first)argumentbox,selectcellA4(thevalueforwhichthecalculationis
made).
2. Selectthe Table_array (second)argumentbox; use the separate table that hasbeencreated
earlier. In our example, the lookup table is in 'PartsList'!A2:D11. Look up table has been
createdintheworksheetnamedPartsListandisinthecolumnsA2toD11.Nowadjustthe
formulasuchthatthetablearraybecomesanabsolutereference,'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,weareusingthe2ndcolumn,hencethevalueis2
4. Range_lookupcanbeeithera0or1,elseyoucoulduseTRUEorFALSE.Ifanexactmatchis
needed,choose0orTRUE.Bydefault,itissetasTRUE.
5. Hence,thelookupfunctiontogetdetailsofaparticularpartnumberwillbe:
=VLOOKUP(A4,Lookup!$A$2:$D$11,2,TRUE)
6. Checkiftheresultisasexpected,andthenclickOK.
19
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
PivotTables
ThePivottablesinExcelareveryusefulandpowerfulfeatureandcanbeusedtosummarize,analyse,
exploreandpresentyourdatawithease.
PivotTablereportisespeciallydesignedfor:
Queryinglargeamountsofdata
Subtotalling and aggregating numeric data, i.e., summarising data by categories and
subcategories,andcreatingcustomcalculationsandformulas.
Expandingandcollapsinglevelsofdatatofocusyourresults,anddrillingdowntodetailsfrom
thesummarydataforareasofinteresttoyou.
Transposingdatamovingrowstocolumnsorcolumnstorows(or"pivoting")toseedifferent
summariesofthesourcedata.
Filtering,sorting,grouping,andconditionallyformattingthemostusefulandinterestingsubset
ofdatatoenableyoutofocusontheinformationthatyouwant,withouthavingtowriteany
formulas
Presentingconcise,attractive,andannotatedonlineorprintedreports.
CreateaPivotTablefromworksheetdata
WhenyoucreateaPivotTablereportfromworksheetdata,thatdatabecomesthesourcedataforthe
PivotTablereport.
1. Selecttherangeofcellsthatcontainsthedataalongwithcolumnheadings.
2. OntheInserttab,intheTablesgroup,clickPivotTable.
3. TheCreatePivotTabledialogboxisopen.
4. UnderChoose the data that you want to analyze,make surethatSelect a table or rangeis
selected,andthenintheTable/Rangebox,makesuretherangeofcellsthatyouwanttouseis
listed.
5. Under Choose where you want the PivotTable report to be placed, choose either the New
WorksheetorExistingWorksheetandclickOK.
20
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
6. An empty PivotTable report is added on the specified worksheet along with the PivotTable
FieldListfromwhichyoucanselectthefieldsthatyouwouldliketoaddtocreatealayoutand
customizethePivotTablereport.
7. To place any field inthe default area ofthe layout section, select the check boxnexttothe
fieldnameinthefieldsection.Bydefault,nonnumericfieldsareaddedtotheRowLabelsarea,
numeric fields are added to the Values area, while date/time hierarchies are added to the
ColumnLabelsarea.
8. Toplaceafieldinaspecificareaofthelayoutsection,youcanalsorightclickthefieldnamein
thefieldsection,andthenselectAddtoReportFilter,AddtoColumnLabel,AddtoRowLabel,
orAddtoValues.
9. Youcouldalsodragafieldtotheareathatyouwantbyclickingandholdingthefieldnamein
thefieldsection,andthendraggingittoanareainthelayoutsection.
Statisticalfunctions
Excelhasawidevarietyofbuiltinstatisticsfunctionsthatgive,forinstance,theslopeandyintercept
ofaline,thestandarddeviationofadatasample,andthemean,medianandmodeofasetofvalues.
Here,wewillcoverafewofthemoreusefulandpopularstatisticsfunctionsfromwhichyoucaneasily
obtainsummarystatisticsdirectly;elseyoucanusetheAnalysisToolavailablefromtheToolsmenu.
BasicStatisticalbuiltinfunctions
21
Function
WhatitDoes
AVERAGE(range)
Returnstheaverageofitsarguments
AVERAGEA(range)
Returnstheaverageofitsarguments,includingnumbers,
text,andlogicalvalues
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
MEDIAN(range)
MODE(range)
Returnsthenumberinthemiddleofarangeofdata
Returnsthemostfrequentlyoccurringorrepetitivevalue
inarangeofdata
COUNT(range)
Countshowmanynumbersareinarangeofdata
COUNTA(range)
Countshowmanyvaluesareinarangeofdata
MAX(range)
Returnsthemaximumvalueofarange
MIN(range)
Returnstheminimumvalueofarange
LARGE(range,n)
Returnsthekthlargestvalueinadataset
SMALL(range,n)
Returnsthekthsmallestvalueinadataset
WewillusethefamiliarexampleofaclassgradestoillustratetheuseofsomeofthemorebasicExcel
functions,likeAVERAGE(),MODE()ANDMAX().Assumeaclasssgradedistributionisasfollows:3,0,
4,4,4,2,4,1,4,0,3,3,1,1,3,4,2,4,0,3,3,1,3.Thesegradesarebasedona4pointscalewith4=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 midC. The syntax for this common function is =AVERAGE(number1,
number2,...).However,wedon'tgetaclearpictureoftheclasssperformancebysimplylookingatits
average.WecanfurtheranalyzethedatausingtheMEDIAN()function.Themediangivesthemiddle
numberinasetofnumbersanditssyntaxis=MEDIAN(number1,number2,...).Whenthemediangrade
iscalculated,itis3.0,meaningthathalfofthegradesarehigherthan3.0,andhalfarelower.Therefore,
despitethelowclassaverage,morestudentsscored3'sand4'sthan2's,1'sand0's.
Additionally,wecanalsoanalyzethegradedistributionbyusingtheMODE()function.Themodegives
the most frequently occurring value of a set of numbers and its syntax is =MODE(number1,
number2,...).Excel'sbuiltinfunctionstodeterminethenumberofgradesentered,andthemaximum
andminimumgradesofthedistribution.
AVERAGEandAVERAGEA
The differencebetween AVERAGE and AVERAGEA becomes evident when oneof the cells contains a
textORASPACEanddon'tforgettheSPACE.AcellcontainingaspaceisNOTempty.
COUNTandCOUNTA
IfyouwanttocountthenumberofcellsthatarenotblankCOUNTandCOUNTAwillreturnadifferent
resultifinoneofthecellsthereisatextoraspace
=COUNT(B2:B7)willreturn6isonlynumbersarepresentincellsB2toB7and5ifthereisaletter,
anemptycellORASPACEinoneofthecells.
=COUNTA(B2:B7) will return 6 unless one of the cells is empty. If all the cells contain numbers,
lettersORSPACEStheresultwillbe6.
22
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
LARGEandSMALL
TheMAXandMINfunctionswouldgivethelargestandsmallestvaluefromalistofvalues.Butwhatif
you want the second or third largest value or the second smallest value, use LARGE and SMALL
functionsasfollows:
=LARGE(A1:A5,2), =LARGE(A1:A5,3), =SMALL(A1:A5,2)
AsamatteroffactsyoucanalsogettheMINandMAXvaluesusingthesefunctions.
=LARGE(A1:A5,1), =SMALL(A1:A5,1)
Linearregressionfunctions
Excel has some builtin functions that allow a method for determining the slope, yintercept,
correlationcoefficient,andRsquaredvaluesofasetofdata.ThefunctionsareSLOPE(),INTERCEPT(),
and CORREL(). These functions are easier and faster to compute than plotting the data. However, a
visualgraphshowstrendsinthedatabetterthananyothertool.
Function
WhatitDoes
SLOPE
Returnstheslopeoftheregressionlinethroughthegiven
datapoints
=SLOPE(ycellrange,xcellrange)
=SLOPE(C2:C6,A2:A6)
INTERCEPT
Calculates the point at which a line will intersect the y
axis using a bestfit regression line plotted through the
knownxvaluesandyvalues
=INTERCEPT(ycellrange,xcellrange)
=INTERCEPT(C2:C6,A2:A6)
CORREL
Returnthecorrelationcoefficientbetweentwodatasets.
=CORREL(ycellrange,xcellrange)
Ifweconsidertheexampleofacarinmotionthatiscomingtoastopandarerequiredtodetermineits
acceleration and initial velocity. Then, we can determine the car's acceleration and its initial velocity
withthehelpoftheSLOPE()andINTERCEPT()functions.Hence,theyaxisvaluesrepresentthesquare
ofthecar'svelocityandthexaxisvaluesrepresentthecarspositionordistancetravelled.Inorderto
findtheacceleration,wedividetheslopeby2andtofindtheinitialvelocity,wetakethesquarerootof
theyintercept.
Distancetravelled
(inm)
2.00
4.00
6.00
8.00
10.00
Velocity SquareofVelocity
(inm/s)
inm2/s2
6.90
47.61
6.00
36.00
4.90
24.01
3.40
11.56
0.00
0.00
TheCORREL()functioncanthenbeusedtoensurethatthedatadisplaysalineartrend.Itisalwaysa
goodideatoplotthedataaswellasusethesestatisticsfunctionsbecausesometimestrendsarenot
obvious.Additionally,aplotofthedataallowsustovisualizethedataandgrossblundersanderrant
datapointsareeasilydetected.
23
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
STDEV
For error analysis, we use the STDEV function. When we carry out a number of repetitive
measurementsofonequantity,wefindtheaveragevalue.Thisdoesnothowevertellusanythingof
theprecisionofourmeasurement.Thestandarddeviationofthemeasuredvalueswillgiveameasure
oftheprecision.Toquicklydeterminethestandarddeviationofanymeasurement,useExcel'sbuiltin
STDEV()function.
=STDEV(A2:A6)
StatisticalAnalysis
MicrosoftExcelhasnumerousAddinfeaturesthatsupportstatisticalanalysis.Statisticaldataanalysis
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
needtobeperformed.Excelisausefultoolforansweringbasicanalysis.Theprimaryreasontouse
Excelforstatisticaldataanalysisisbecauseitissowidelyavailable.
ThereareanumberofdisadvantagesworthconsideringbeforeusingExcelforstatisticalanalysis:
Missingvaluesarehandledinconsistently,andsometimesincorrectly.
Datahastobeorganiseddifferentlyaccordingtotheanalysisyouwishtoperform.
Mostanalysescanonlybedoneononecolumnatatime.Thismakesitinconvenienttodothe
sameanalysisonmanycolumns.
Thereisnologorrecordofhowananalysiswasaccomplished.
Italsolacksmanyimportantfeaturesforadvancedanalyses.
UsingtheAnalysisToolPak
Twospecifictoolsareusefulingeneratingdescriptivestatisticsandhistogramsofgradedistributions.
Toaccessthesefeatures,theAnalysisToolPakmustbeloaded.
Ifthemenuisnotvisible,then
1. ChooseAddInsfromtheExcelOptionsfoundthroughtheMicrosoftOfficeButton.
24
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
2. IntheManagedropdownmenu,selectExcelAddins,andclickGo.
3. IntheAddInsavailablebox,selecttheAnalysisToolPakcheckbox,andthenclickOK.
4. IfyougetpromptedthattheAnalysisToolPakisnotcurrentlyinstalledonyourcomputer,click
Yestoinstallit.
5. A configuration progress screen for Microsoft Office appears and once completed, the Data
AnalysismenushouldappearontheDatamenuintheAnalysisgroup.
DescriptiveStatistics
The quickest waytoget meanandstandarddeviation foranentire groupisbyusingtheDescriptive
Statistics in the Data Analysis tools. This generates simple descriptive statistics like average, median,
25
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
andstandarddeviationforacollectionofdata.YoucanchooseseveraladjacentcolumnsfortheInput
Rangeandeachcolumnisanalysedseparately.Thelabelsinthefirstrowareusedtolabeltheoutput,
andtheemptycellsareignored.Iftherearemorenonadjacentcolumnstobeanalysed,thenonehas
to repeat the process for each group of adjacent columns. The procedure is straightforward, can
managemanycolumnsreasonablyefficiently,andemptycellsaretreatedproperly.Togeneratethese
statistics,
1. FromtheDatamenuintheAnalysisgroup,selectDataAnalysis.
2. TheDataAnalysisdialogboxopens.
3. IntheDataAnalysisdialogbox,chooseDescriptiveStatistics.
4. IntheDescriptiveStatisticsdialogbox(seebelow),specifythecellsthatcontainyourdatain
theInputRangebox.SelecttheSummaryStatisticscheckboxinthelowerleftcorner.
5. Bydefault,thestatisticsisgeneratedonanewworksheet.Ifyouwantthestatisticstoappear
onthe same worksheet,clickthe Output Rangebutton and specify a destinationcell forthe
statistics.Youcanalsospecifyanameforthenewworksheet.
26
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning
SampleoutputfromtheDescriptiveStatisticstoolappearsasshowninthetablebelow.
MeasuredValues
Mean
343.491
StandardError
0.666719
Median
344
Mode
344
StandardDeviation
2.981658
SampleVariance
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
ConfidenceLevel(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
looksthesametotheleftandrightofthecenterpoint.Kurtosisisameasureofwhetherthedataarepeakedorflatrelativeto
anormaldistribution.
MoreInformation
ExcelHelp
ExcelhasaHelpsystembuiltintothesoftware.Youcanclickon atanytimeandbrowsethrough
thetopicsforyourspecifictopicorcansearchforitusingthesearchoption.Togethelpwithaspecific
procedure,clickontheHelponthisfunctionintheDialogboxfortheprocedureyouwouldliketorun.
Officeonline
Microsoft alsooffers a verycomprehensiveonline help at the Microsoftoffice Help forExcel 2007,
http://office.microsoft.com/enus/excel/FX100646951033.aspx?CTT=96&Origin=CL100570551033
27
FormulasandFunctionswithExcel
KiruthikaRagupathi,email:kiruthika@nus.edu.sg
CentreforDevelopmentofTeachingandLearning