22
CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions Sum, Min, Max, Average, Count Large, Small, Rank Round Countif & Sumif

CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

Embed Size (px)

Citation preview

Page 1: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Using Functions in ExcelUsing Functions in Excel

Objectives: Using Excel functionsSum, Min, Max, Average, CountLarge, Small, Rank RoundCountif & Sumif

Page 2: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

A Function is a predefined worksheet formula

A Function is a predefined worksheet formula

The advantage of using a function: Saves time Simplifies complex calculations Faster Less chance of typographical errors Fewer characters in the formula bar

Example: instead of =A1+A2+A3+A4+A5use =SUM(A1:A5)

Page 3: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

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.

Functions take arguments and return a resultFunctions take arguments and return a result

Page 4: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

The SUM FunctionThe SUM Function Syntax: SUM(number1,number2)

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.

Page 5: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Function WizardFunction Wizard Function wizard: A short-cut to all the

functions in excel (use fx toolbar button) that walks you through building a function

Page 6: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Using functionsUsing functions

1

2

3

4

5

6

7

8

9

10

11

A B C D E F G H

Grade BookLab1 Lab2 MT Final Total Percent

Total Possible points Honors 10 20 100 200 330

Blue H 9 15 88 186 298 90.3%Jones 5 77 155 237 71.8%Smith H 10 18 91 190 309 93.6%Grey 7 10 75 155 247 74.8%

Highest Score 10 18 91 190 309 93.6%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)

Page 7: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

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

Arguments of a SUM function Arguments of a SUM function

Page 8: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Common Functions- with only a range argument

Common Functions- with only a range argument

= SUM(number1,number2 ,…) Sums a range of values = AVERAGE(number1,number2 ,…) Averages a range of values = MIN(number1,number2 ,…) Returns minimum value in a range = MAX(number1,number2 ,…) Returns maximum value in a range

= COUNT(number1,number2 ,…) Returns the number of items in a range

= STDEV(number1,number2 ,…)Returns standard deviation of a the values in the range

Where number1, number2 are 1 to 255 numeric arguments.Arguments can either be numbers, ranged names or ranges of cell references which contain numbers.

Page 9: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Inserting Rows/Columns into the Data Inserting Rows/Columns into the Data

What would happen to the value in cell B6 if we insert a row between 3 and 4 and add the order# 301 with the quantity of 1000?

(1) Assume the formula in cell B6 is originally =A2+A3+A4+A5

(2) Assume the formula in cell B6 is originally =SUM(A2:A5)

Cell references are modified but the new row is not included with ‘+’. The new row is included with the SUM.

123456

A BOrder# Quantity

234 25244 10299 1345 100

Total: 136

Page 10: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

How a function’s algorithm can affect the resulting value

How a function’s algorithm can affect the resulting value

How does the Average function algorithm treat blank cells?

What value will result in cell A5 if it contains the formula =AVERAGE(A1:B4)?

12345

A1020

30=AVERAGE(A1:A4)

Blank cells are ignored the resulting value is 20

Page 11: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Many functions consist of several argument types

Many functions consist of several argument types

LARGE(array, k) Large(B2:B5,2) will return the 2nd highest value in the range B2 to B5

SMALL(array,k) Small(B2:B5,2) will return the 2nd lowest value in the range B2 to B5

What would happen if you tried to use a non-continuous range in these functions =Large(B2:B5,E2:E5,2)?

=Large(B2:B5,E2:E5,2) -- The comma tells the computer the next argument is the criteria – so the range E2:E5 is interpreted as the k value and an error will result.

Page 12: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Use the Large function to Calculate the total lab score dropping the lowest scoreUse the Large function to Calculate the total lab score dropping the lowest score

The following formula with count only the 4 highest scores: =LARGE(C3:G3,1) + LARGE(C3:G3,2)+

LARGE(C3:G3,3) + LARGE(C3:G3,4) Is this formula always equivalent to

=SUM(C3:G3)-SMALL(C3:G3,1)?

1

2

3

4

5

6

A B C D E F G H

Lab1 Lab2 Lab3 Lab4 Lab5 TOTALBlue H 21 15 12 25 22Jones 15 25 25 24 26Smith H 10 18 5 15Grey 7 10 21 19 17

Grade Book

Page 13: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Setting up a Ranking Table using the LARGE/SMALL Functions

Setting up a Ranking Table using the LARGE/SMALL Functions

12345

A B C D EQuantity Highest Smallest

25 1 100 110 2 25 101 3 10 25

100

=LARGE(A$2:A$5,C2)

=SMALL(A$2:A$5,C2)

Page 14: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Ranking a List: RANK(Number, Ref, Order)

Ranking a List: RANK(Number, Ref, Order)

The rank function will give you the rank order of a specific value from a list of values.

Cell I3: =RANK(H3,H$3:H$6,1) – 83 is the third lowest value

Cell J3: =RANK(H3,H$3:H$6,0) – 83 is the second highest value

Notice Lee’s Rank is also 3 and there is no Rank 4

Page 15: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Syntax: Round (number, num_digits) = Round (24.44,1) results in the value 24.4 What value will result if you write the formula

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

The Round Function changes the precise value of a number, not just its display

The Round Function changes the precise value of a number, not just its display

810

ROUND(AVERAGE(C1:C10),-1)

Page 16: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

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 COUNTIF Function counts the number of items in a range that meet a specific criteria.

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

Page 17: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

A B C D E F1 MT1 MT2 Final Total

2Possible points 100 100 200 400

34 Blue 79 89 169 3375 Jones 85 65 195 3456 Grey 60 97 187 34478 Max 85 97 195 345

How many people scored above 70 points on Midterm 1?

Using the COUNTIF FunctionUsing the COUNTIF Function

=COUNTIF(B4:B6, “>70”)

Page 18: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

SUMIF(range, criteria, sum-range) Range – Continuous range used to compare the criteriaCriteria – Comparison CriteriaSum-Range - If criteria is met, the computer will sum

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

The SUMIF Function sums the values in a range that meet a specific criteria

The SUMIF Function sums the values in a range that meet a specific criteria

Page 19: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Simple Examples of Using SUMIFSimple Examples of Using SUMIF

12345678

A B C DStudent College Rank Scholarship

Mandy BUS 4 2,675$ Aaron HEC 3 4,000$ Robert SBS 2 3,850$ Tricia ENG 4 2,250$ Ragu BUS 3 3,200$ Michelle BUS 4 2,400$ Amanda HEC 1 2,900$

=SUMIF(B2:B8, "BUS", D2:D8)

Write a formula to determine the total value of all scholarships for BUS majors:

Write a formula to determine the total value of all scholarship awards that are over $3000:

=SUMIF(D2:D8,">3000")

Page 20: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

What formula can be written in cell C13 to determine the average freshman GPA for Graduating Seniors in

BUS? How can we make the formula work when copied both down and across?

What formula can be written in cell C13 to determine the average freshman GPA for Graduating Seniors in

BUS? How can we make the formula work when copied both down and across?

123456789

101112131415

A B C D E F GGraduating Senior Stats:Student College Freshman Sophmore Junior Senior OverallTom BUS 2.1 3.2 3.4 3.5 3.05Sara HEC 3.8 3.8 3.2 3.9 3.68Michael SBS 2.85 3.1 3.3 3.2 3.11Todd ENG 4.0 4.0 4.0 4.0 4.00Regina BUS 3.9 3.7 3.2 3.8 3.65Ming BUS 3.2 2.7 2.6 1.9 2.60Alexis HEC 1.5 2.6 2.0 1.9 2.00

College Freshman Sophmore Junior Senior OverallBUS 3.1 3.2 3.1 3.1 3.1HEC 2.7 3.2 2.6 2.9 2.8SBS 2.9 3.1 3.3 3.2 3.1

Summary By College By Year

=SUMIF($B$3:$B$9,$B13,C$3:C$9)/COUNTIF($B$3:$B$9,$B13)

Page 21: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

Other Categories of FunctionsOther Categories of Functions•Statistics:

•Mean, Median, Standard deviation

•Financial:•Present value, Future value

•Logical:•NOT, AND, OR

•Trigonometric:•COS, TAN,

Page 22: CS&E 200 Exfunctions Using Functions in Excel Objectives: Using Excel functions l Sum, Min, Max, Average, Count l Large, Small, Rank l Round l Countif

CS&E 200 Exfunctions

What we’ve learned about functionsWhat we’ve learned about functions Functions are formula “shortcuts” – to use a function you

need the function name and to enter the function arguments in the correct order and observe the specified rules.

Functions can be input into the worksheet either by directly typing them, in some cases using the AutoSum button on the toolbar or by using the function wizard.

The functions SUM, MIN, MAX, AVERAGE, & COUNT all have a single argument – a range and ignore blank cells and text.

More complex functions covered include LARGE, SMALL, ROUND, COUNTIF and SUMIF.