ENGG1003 02 SpreadsheetApplication
ENGG1003 02 SpreadsheetApplication
Computational Thinking—P
Introduction to Spreadsheet
1
Spreadsheet Application
An application for
entering, analyzing,
and presenting
numerical data
Provides "what-if"
analysis
Microsoft
Excel
VisiCalc (The first
spreadsheet program)
Google
Sheets Apple
Numbers
3
Spreadsheet: Concepts
Column Column …
A B
Row
1
Row The active
2 cell
…
Formula bar:
Shows the
content
of the active cell
5
Ente
Formula r
7
Formula and Address
In a formula, a To refer to a cell
simple cell in another
address, e.g., worksheet, use
B3, denotes the “!”
address in the E.g.: Sheet2!B3
current means cell B3 of
(displaying) worksheet
“Sheet2”
worksheet
8
Function
Most spreadsheet programs provide
many useful built-in functions
Saveyou the need to "reinvent the
wheel"
=max(D2:D11
)
The data inside
( ) are called
arguments.
=min(B2:B11
=average(C2:C11
)
)
12
Common Errors when Using Formulas
Unmatched ( )
E.g., =(-3 + sqrt(7)) / 2)
“Circular reference”:
In A1: =A2 In A2: =A1
13
Copy and Paste a Formula
Sometimes we may want to apply
essentially the same formula to
different sets of data
To automate the process, a common
practice is by “copy and paste”
Copy
(Ctrl-C/⌘-
C)
Paste
(Ctrl-V /⌘-
V)
14
Copy and Paste a Formula
Besides the usual way of doing
“copy and paste”, you can also do so
by mouse dragging
1. Click and Result:
drag the
bottom
right corner
of this cell
drag
2. Release
mouse click
here
15
Copy and Paste a Formula
After copy and paste, the addresses in a
formula may change
The change depends on the positional
difference between the cells being copied
and pasted Addresses
changed!
17
What if I don’t want address changes?
=A$1+
$B2
Try to copy C4 to E4, C6, and E6
18
Relative vs Absolute Addressing
Copy
=A$1+ =C$1+
$B2 $B2
Paste
=A$1+ =C$1+
$B4
Paste $B4
Paste
=sum(A$2:A2 Copy
)
=sum(A$2:A3 Paste
)
=sum(A$2:A4 Paste
)
=sum(A$2:A5 Paste
)
…
20
Relative vs Absolute Addressing
The $ sign can be added to both row
and column name in an address
=$A$1+B =$A$1+C
2
Copy 2
Paste
Paste Paste
=$A$1+B =$A$1+C
4 4
21
Define Name
Defining a name allows us
referring to a particular
piece of data (at certain
address) conveniently when
working with formulas
22
Using a Defined Name
To Apply a Defined Name, pick it
from the menu OR simply
spell it explicitly in a formula!
Ente
r
23
Plotting Chart
2 3
Select cells E1 to
F8
24
Try choosing other chart
Plotting Chart types to see the
difference!
25
Conditional Formatting
2
1
Example:
=if(B2<=C2,"oh no",D2)
E.g.: =countif(A1:A5,"<=50")
(Count the number of
cells in B1:B5 that is less
than or equal to 50)
Detailed usage:
https://support.office.com/en-us/article/COUNTIF-function-E0DE10C6-F885-4E71-ABB4-1F464816DF34 28
Some Useful Functions
sumif(range, criteria, [sum_range])
Sums the values in range that meet
criteria
E.g.: =sumif(A1:B3, ">=10")
Sums all cells in A1:B3 that is >= 10
(Result is 12+32+31=75)
E.g.: =sumif(A1:A4, "John", B1:B4)
Sums the values in B1:B4 where the
corresponding cells in A1:A4 equal
"John" (Result is 21+5=26)
Usage:
https://support.microsoft.com/en-us/office/sumif-function-169b8 29
Pivot Table
Excel provides a very useful data
summarization and analysis tool,
called Pivot Table
table to be analyzed
30
INSERT PivotTable
31
Created a New Worksheet
32
Choose/ Drag-and-Drop Fields
Refresh as needed
(when Sheet1 data has
changed)
33
Some Useful Functions
vlookup(lookup_value, array, col,
[range])
Search the first column of a range of
cells (array), and then return a value
from any cell on the same row of array
E.g., try the following formula with
this table
=vlookup(1155086737, A2:C7, 3,
false)
Detailed usage:
https://support.microsoft.com/en-us/office/vlookup-fu
nction-0bbc8083-26fe-4963-8ab8-93a18ad188a1
34
vlookup()
Searches 1155086737 in the first
column of A2:C7 (i.e., col A)
Row 4 matches. So returns the third
column of data in row 4 (i.e., C4)
The fourth argument, false, denotes
“exact match”
=vlookup(1155086737, A2:C7, 3,
false)
35
Data Filtering and Sorting
Filtering allows you to display only
the rows of data that meets certain
criteria that you specify.
E.g., what if I
want to show
only the data
of one
particular
sales/branch?
36
Creating Filters
2
3
Select columns A to
D
37
Using Filters
You can click on
the filter icons .
(Try clicking the
one in column B)
38
: filter applied
: values
Using Filters sorted
39
More Useful Functions
frequency(data, bins)
data is a range of cells for which you
want to count
bins is another range of cells into which
you want to group
Calculates how often values occur
within a range of values
Step 2: Type
=frequency(B2:B16,D2:D7
)
(without pressing ENTER)
Step 3:
Ctrl+Shift+Enter
41
frequency(): Example
Example: Row 2
and
column 3
=index(B2:D5,2,3 of B2:D5
) 43
More Useful Functions
row()
Return the row number of a cell
column()
Return the column number of a cell
Examples:
Cel Formula Resul
l t
C8 =row() 8
E10 =column()^2 25 44
Summary
Basic concepts of spreadsheet
Formulas
Common useful functions
Relative vs absolute addressing
Plotting Charts
Conditional Formatting
Pivot Table and data analysis
Data Filtering and Sorting
Appendix: a Bigger Example and Additional Useful
Functions (see coming pages)
45
Appendix: A Bigger (and More
Complicated) Example
Find the “window sum” of some given data
Dat
2-Window Sum 4-Window Sum
a
58 58 + 47 = 105 58 + 47 + 16 + 20 = 141
47 47 + 16 = 63 47 + 16 + 20 + 77 = 160
16 16 + 20 = 36 16 + 20 + 77 + 80 = 193
20 20 + 77 = 97 20 + 77 + 80 + 98 = 275
77 77 + 80 = 157 77 + 80 + 98 + 90 = 345
80 80 + 98 = 178 80 + 98 + 90 + 46 = 314
98 98 + 90 = 188 98 + 90 + 46 + 63 = 297
90 90 + 46 = 136 -
46 46 + 63 = 109 -
46
Easy?
=sum(A2:A5
)
=sum(A2:A3
)
47
k-window Sum
When D2 is 3, compute
3-window sum.
When D2 is 4, compute
4-window sum.
…
=sum(A2:index(A1:A11, row()+D2-1,
1))
51
To Wrap Up…
Simply copying B2 to B3, …, B11
does not work. (Why?)
We have to consider:
Which cell addresses in the formula
should not change upon “copy and
paste”?
=sum(A2:index(A1:A11, row()+D2-1,
1))
=sum(A2:index(A$1:A$11, row()+D$2-1,
1)) 52
To Wrap Up…
After “copy and paste”
=sum(A2:index(A$1:A$11, row()+D$2-1,
1))
=sum(A5:index(A$1:A$11, row()+D$2-1,
1))
This is normal.
(Why?)
53
Testing
Try modifying D2 to other values to
check if the results are correct
54
Disclaimer
All company and product names are
the trademarks of the respective
companies
55