0% found this document useful (0 votes)
15 views55 pages

ENGG1003 02 SpreadsheetApplication

Uploaded by

selina.hu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views55 pages

ENGG1003 02 SpreadsheetApplication

Uploaded by

selina.hu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 55

ENGG1003 Digital Literacy and

Computational Thinking—P

Introduction to Spreadsheet

1
Spreadsheet Application
 An application for
entering, analyzing,
and presenting
numerical data

 Usually displays a 2-D


grid consisting of rows
and columns

 Provides "what-if"
analysis

Download your free copy of Office apps:


https://www.itsc.cuhk.edu.hk/all-it/email-messaging-and-collaboration/office-365-proplus 2
Spreadsheet ≠ Microsoft Excel

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

A cell address (or


reference) is the
One workbook can have combination of its
multiple worksheets (i.e., row
multiple grids of cells) and column. E.g., C8
A grid of cells
4
Spreadsheet: Concepts

Formula bar:
Shows the
content
of the active cell

Cell content can be:


• Text
• Number
• Date and time
• Formula

5
Ente
Formula r

 Identify the calculations needed to


place the result in a cell
 Start with the = sign

E.g.: Cel Formula Meaning Result


l
A1 =2+5*3 17
B1 =3*(A1-4) 39
A2 =B1^2.3 4565.082139
B2
Addition =sqrt(A2)
:+ Multiplication : * 67.56539158
Power :
^
6
Formula
 + - * / ^ are called operators
 sqrt() is called a function

 While the cell shows the calculation


result, the formula bar shows the
actual formula
 Toedit a formula, do it in the formula
bar

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"

 For example, instead of typing:


 =A1+A2+A3+A4+A5+A6+A7+A8+A9
 we can simply type: =sum(A1:A9)

Note: A1:A9 means the


range
of cells A1, A2, …, A8, A9 9
Common Mathematical Functions
Function Meaning
abs(…) Absolute value
sqrt(…) Positive square root
exp(…) e raised to the power of a number
log(…) Base-10 logarithm
ln(…) Natural logarithm (i.e., ln in
calculator)
sin(…), asin(…), Trigonometry functions (in radians,
cos(…), acos(…), i.e., )
tan(…), atan(…)
pi() 10
Common Statistical Functions
Function Meaning
min(…) Find the minimum value among
some values
max(…) Find the maximum value among
some values
average(…) Compute the mean of some values
sum(…) Give the sum of some values
stdevp(…) Compute the standard deviation of
some values
median(…) Find the median of some values
List of all Excel functions with usage help:
https://support.microsoft.com/en-us/office/excel-functions-by-category-5f91f4e9-7b42-46d2-9bd1-63f26a86c0eb
11
Function: Examples

=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!

E.g., copy D2 and paste to D6; positional difference is 4


rows.
16
Exercise
 Suppose:

 What will be the results if we copy D1 and


paste to:
 D2, …, D5?
 E1, …, E5?
 F1, …, F5?

17
What if I don’t want address changes?

 Use the $ sign in a cell address to


affect what happens when a formula
is copied to another cell
 E.g., suppose:

=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

 Placing $ before a row/column name


in a formula forces it not to change
when the formula is pasted to
another cell
Using $ in an address in a
formula
is called absolute addressing 19
Relative vs Absolute Addressing
 One practical usage of absolute
addressing is to compute
cumulative total of some values

=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

Allows adding special formatting


effects to your data according to
some specified criteria 26
Some Useful Functions
 if(test, t_value, f_value)
 test is a logical test (yielding true or
false)
 Return t_value if test is true (yes)

 Return f_value if test is false (no)

Example:

=if(B2<=C2,"oh no",D2)

Comparison operators: Not


< <= > >= = equa
l 27
Some Useful Functions
 countif(data, criteria)
 Count the number of cells that satisfy
some given criteria
 data is a range of cells

 criteria is the criteria to be satisfied

 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

 Let’s begin with


 switching to a target worksheet;
 clicking on the top-left cell of the data

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)

Change the labels as


needed

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)

You can sort the data


according to the sales names.

You can choose to show only


the data of one or more sales.

38
: filter applied
: values
Using Filters sorted

• Shows data of:


 sales “LAW, Yuk Chun” or
“FUNG, Pang Fong”; AND
 branches Central or
Shows data of sales “LAW, Yuk
Causeway Bay
Chun” or “FUNG, Pang Fong” only • Sorted in decreasing revenue

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

 This function returns more than one


value!
Detailed usage:
https://support.microsoft.com/en-us/office/frequency-function-44e3be2b-eca0-42cd-a3f7-fd9ea898fdb9
40
frequency(): Example
Step 1: Select cells F2 to
F8

Step 2: Type
=frequency(B2:B16,D2:D7
)
(without pressing ENTER)

Step 3:
Ctrl+Shift+Enter

41
frequency(): Example

 score ≤ 39: 1 time


 39 < score ≤ 49: 2
times
 49 < score ≤ 59: 1
time
 59 < score ≤ 69: 2
times
 69 < score ≤ 79: 4
times
 79 < score ≤ 89: 3
times 42
More Useful Functions
 index(array, i, j) This is a function
with 3 arguments
 array is a range of cells
 i is a row number
 j is a column number

 Return the element in the i-th row and

j-th column of array

 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
)

 What if we want to find k-window sum,


where k is a value stored in another cell?

47
k-window Sum
When D2 is 3, compute
3-window sum.
When D2 is 4, compute
4-window sum.

Let’s start with the formula in


B2

What is the row


number of the last
element in the
sum?
48
k-window Sum
The sum in B2 should run
from row 2 to row 2+k-1

The sum in B3 should run


from row 3 to row 3+k-1
So, the row in which the
sum ends is: row()+D2-
1
k
So, the cell in which the sum ends
is:
index(A1:A11, row()+D2-1, 1) 49
k-window Sum
 For B2, we need to sum from A2 to
index(A1:A11, row()+D2-1, 1)

Type formula here:


=sum( A2: index(A1:A11, row()+D2-1,
=sum(A2:index(A1:A11, 1) )
row()+D2-1,
1))
50
k-window Sum
 So far so good. Try changing k to
another value

=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

 The copyright of all application


screen shots belongs to the
respective companies

55

You might also like