0% found this document useful (0 votes)
3 views

lec_2

This lecture covers mathematical and statistical functions in Excel, focusing on the use of predefined functions like SUM, AVERAGE, COUNT, and their applications in calculations. It explains the syntax, arguments, and algorithms for these functions, as well as logical functions such as AND, OR, and NOT for decision-making. Additionally, it introduces the COUNTIF and SUMIF functions for conditional counting and summing based on specified criteria.

Uploaded by

ppasty93
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

lec_2

This lecture covers mathematical and statistical functions in Excel, focusing on the use of predefined functions like SUM, AVERAGE, COUNT, and their applications in calculations. It explains the syntax, arguments, and algorithms for these functions, as well as logical functions such as AND, OR, and NOT for decision-making. Additionally, it introduces the COUNTIF and SUMIF functions for conditional counting and summing based on specified criteria.

Uploaded by

ppasty93
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

Lecture # 2

Mathematical And
Statistical Packages
Course code: MC300

1
A Function is a predefined worksheet formula

◦The advantage of
◦using a function:
◦Saves time writing
◦Simplifies complex calculations
◦Faster execution
◦Less chance of typographical errors
◦Fewer characters in the formula bar
◦ Example: instead of =C5+C6+C7+C8
◦ use =SUM(C5:C8)

2
Functions take arguments and return a result

The general format of a function is -


=Functionname(arguments)
◦Arguments – argument variables are used by the
function to calculate the result. Arguments appear in a
specific order.
◦Syntax – specific format required to use a function its
name and order of arguments
◦Result – the value calculated by the function
◦Algorithm – a step-by-step procedure for
accomplishing some end task.

3
The SUM Function
◦Syntax: SUM(range) or SUM(num1, num2, …)
Can type into cell, use AutoSum toolbar button or function
wizard
◦Argument: Value or Range of cells to be summed
◦Algorithm: Arithmetic sum of all values listed in
the range argument

Example: In the formula =SUM(B2:B8) * 3 Excel will add the


values in cells B2 through B8 and then multiple the result
by 3.

4
Arguments of a SUM function
Valid Range Arguments for a SUM function
◦A1:A4 - Range along a column
◦A1:D1 - Range along a row
◦A1:D4 - A two-dimensional range
(Block)
◦A1, D3:D5, 7 - non-contiguous cells*
* not all range arguments of functions can be used with non-contiguous cells

5
Using functions
A B C D E F G H
1 Grade Book
2 Lab1 Lab2 MT Final Total Percent
3 Total Possible points Honors 10 20 100 200 330
4
5 Blue H 9 15 88 186 298 90.3%
6 Jones 5 77 155 237 71.8%
7 Smith H 10 18 91 190 309 93.6%
8 Grey 7 10 75 155 247 74.8%
9
10 Highest Score 10 18 91 190 309 93.6%
11 Lowest Score 5 10 75 155 237 71.8%

What formula is written in cell G5 and copied down


the column to determine the total points earned by
the corresponding student? (grades.xls)

=SUM(C5:F5)
6
Function Wizard
◦Function wizard: A short-cut to all the functions in excel
(use fx toolbar button) that walks you through building a
function

7
Common Functions- with only a range argument

SUM(number1,[number2],…) Adds the numbers in a range of cells


AVERAGE(SUM(number1, Calculates the arithmetic mean
[number2],) of a list of values

MIN(SUM(number1,[number2],…) Returns the smallest number of


a range of values

MAX(SUM(number1,[number2],…) Returns the largest number of a


range of values

COUNT(value1,[value2],…) Determines the number of cells


in a range that contain numbers
COUNTA(value1, [value2],…) Counts non-blank cells

Where number1, number2 are 1 to 255 numeric arguments.


Arguments can either be numbers, ranged names or ranges
of cell references which contain numbers.
8
How a function’s algorithm can affect the resulting value

◦How does the Average function algorithm A


1 10
treat blank cells? 2 20
◦What value will result in cell A5 if it 3
4 30
contains the formula =AVERAGE(A1:A4)? 5 =AVERAGE(A1:A4)

Blank cells are ignored  the


resulting value is 20

9
How many Honor students are there?

=COUNT(B5:B8
)?

The COUNT function ignores blank cells and


text  the resulting value is 0

Use =COUNTA(B5:B8)  2
10
If scores should only be reported as integers.. How can
we fix this in Excel?

The
Increase/Decrease
decimal buttons do
NOT change a value
only how the value
is displayed.
Use the ROUND function to change the
precision of a value 11
The Round Function changes the precise value of a
number, not just its display

Syntax: Round (number,


num_digits)
◦ = Round (24.44,1) results in the value 24.4
◦ The ROUND function can be part of a larger formula:
 810
◦ What value results: =Round (B2,0)*10 if cell B2 contains the
value 81.3?
◦ How would your write a formula to round the average value in
cells Cl:C10 to the nearest ten?
ROUND(AVERAGE(C1:C10),-
1)
12
The num_digits argument
◦Positive num_digits round to the
specified number of decimal places
◦A zero results in a whole number
◦Negative num_digits round values
to tens, hundreds etc.

13
Notice the Σ SUM gives different results
when adding rounded values

The formula in cell C2 is =B2 – copied down


The formula in cell D2 is =Round(B2,0) –
copied down 14
The formula in Cell B5 is =SUM(B2:B4) -
Counting the number of honor students

How can we count the number of honor students if regular


students have the letter R in the honor’s column? Before we used
a COUNTA and ignored blanks but counted text.

15
Use the COUNTIF Function

The COUNTIF function counts the number of


values that meet a specified criteria:
=COUNTIF(B5:B8, “H”)

16
The COUNTIF Function counts the number of items in a
range that meet a specific criteria.

COUNTIF (range*, criteria)


Range - a continuous cell range
Criteria Syntax:
- A number 6 =COUNTIF(B2:B7,6)
- Text “USA” =COUNTIF(A1:A50,“USA”)
- A cell reference B2 =COUNTIF(C3:C10,B2)
- A Boolean expression “>5” =COUNTIF(A1:A10,“>5”)

* The comma tells the computer the next argument is the


criteria – so you cannot list individual cells separated by a
comma for the range
17
How many people scored above 6 points on either lab?

X
=COUNTIF(C5:C8,D5:D8, “>6”)

=COUNTIF(C5:D8, “>6”) √
18
The SUMIF Function sums the values in a range that meet a
specific criteria

◦ SUMIF(range, criteria, sum-range)


Range – Continuous range used to compare the criteria

Criteria – Comparison Criteria


Sum-Range - If criteria is met, the computer will sum the
corresponding entry in this range
The syntax of the criteria is the same as the syntax of the COUNTIF
function:
- a number such as 6
- text such as “Honor”
- a Boolean value such as “<2”
- a cell reference such as A1 19
Sumif Function
Write a formula in cell C9,
which can be copied down
the column, to summarize
the number of courses
being taken by students in
this college

=SUMIF(B$2:B$6,A9, C$2:C$6)
20
◦Use the AVERAGEIF function to average values that
meet a specified criteria – average number of courses
taken by students in each college

=AVERAGEIF(B$2:B$6,A9,
C$2:C$6)

– works identically to
AVERAGEIF(range, criteria, averagif-range)
the SUMIF function except it averages the specified
range. 21
A little harder..calculate the average sum for students by
college by year

=AVERAGEIF($B$3:$B$9,$B13,C
$3:C$9) 22
Other Categories of Functions
• Statistics:
• Mean, Median, Standard deviation
• Financial:
• Present value, Future value
• Logical:
• NOT, AND, OR
• Trigonometric:
• COS, TAN,
23
BREAK
24
Microsoft Excel Logical Functions
Objectives:
Using Boolean Logic in Spreadsheets

Relational operators

Boolean operators –Functions

None of logical construct

Using Conditional Formatting

25
Boolean Logical Values
Is 3 greater than 5 ?
The answer is either True or False
TRUE and FALSE are Boolean Values
Mathematically this would be represented by the
expression 3>5
How much greater is 5 than 3?
This answer requires an arithmetic value
Mathematically this would be represented by the
expression 5 - 3

26
Boolean Logical Values
◦Excel provides a class of operators known as Relational
Operators that can be used to perform a comparison of
the left and right sides of an expression

<, >, <=, >=, =, <>

The result is always either TRUE or FALSE

Relational Expressions:

=38<=6 results is the value FALSE

=B2=5+3 results is the value TRUE if B2 equals 8

27
Simple Relational Expressions
•Blue’s total is higher than
Jones’ grade: =E4>E5
•Jones’ total is the maximum
in the class: =E8=E5
•The average total of
students is less than 300:
=Average(E4:E6)<300

28
Precedence of Relational Operators
Are these expressions
equivalent?
=B4+B5<=1
50
=(B4+B5)<
=150

Relational operators are always evaluated last…

29
Boolean Logic Operators
How do you determine if all of the students got
above 320 points to pass the class or if anyone got
below 320 points?

We can use Boolean


Operators - each
operator has a
corresponding Excel
Function
AND, OR, NOT
30
Boolean Logic Operators
◦AND - All items must be true for the statement to be true

◦OR - At least one item must be true for the statement to be true

◦NOT – switches a True to a False and a False to a True

31
The AND Function
Excel uses a Function to perform the AND operation

Syntax: =AND(logical1,logical2, ...)


Returns TRUE if all its arguments are TRUE; returns FALSE if one or more
arguments is FALSE

=AND(TRUE, TRUE) TRUE


=AND(F5,F6) where cell F5=TRUE & cell F6= TRUE  TRUE
=AND(F5:F10) where cell F10=FALSE  FALSE
=AND(3>B7, 2+4=5) equals the value FALSE where cell B7=1

For more details on how it treats text or blanks, look at the


function on Excel help.

32
The AND Function

Is everyone in the class an Honors student?


=And(F4:F6)
Did everyone pass the course? - the passing
score is 320 points
= And(E4>=320, E5>=320, E6>=320)
33
The OR Function
Excel uses a Function to perform the
OR operation
Syntax:
=AND(logical1,logical2, ...)
Returns TRUE if any of its arguments are
TRUE; returns FALSE only if all arguments
are FALSE
=OR(TRUE, FALSE) TRUE
=OR(F5,F6) where cell F5=FALSE & cell F6= FALSE
FALSE

34
The OR Function

Is anyone in the class an Honors student?


=OR(F4:F6)
Did at least one student pass the course -
the passing score is 320 points
= OR(E4>=320, E5>=320, E6>=320)
Can we just write OR(E4:E6>=20)? 35
The NOT Function
Excel uses a Function to perform the NOT
operation
Syntax: =NOT(logical)
Reverses the value of its argument. Turns a TRUE to a
FALSE - and a FALSE to a TRUE.
Use NOT when you want to make sure a value is not
equal to one particular value.
A NOT function takes only ONE argument

=NOT(FALSE) equals the value TRUE


=NOT(F3) where F3=True equals the value FALSE
=NOT(3>5) equals TRUE
36
The NOT
Function

Blue is not an Honors student


=NOT(F4)
Blue didn’t get a passing grade (320)?
=NOT(E4>=320)
is the same as E4<320

37
i c e
r a ct
e P
r
Mo

•Blue’s total and Jones’ total are greater than


Grey’s:
=AND(E4>E6, E5>E6)  FALSE
•Grey’s total is not the maximum grade:
=NOT(E6=MAX(E4:E7))  TRUE
•None of the students passed the course
= NOT(OR(G4:G5))  TRUE
38
What we’ve learned using Boolean Logical Constructs in
Decision Making

◦A relational expression can be used to compare


two values.
◦To determine if a list of logical arguments are ALL
true use the AND function. (every, both)
◦To determine if at least one value is TRUE from a
list of logical arguments use the OR function. (any,
some)
◦Use the NOT function to change a TRUE value to
FALSE and visa versa. Combine a NOT(OR()
construct to determine if none of the values are
TRUE.
39
QUESTIONS?
40

You might also like