http://web.cse.ohio-state.edu/~ricel/ 1. common functions 2
TRANSCRIPT
1
http://web.cse.ohio-state.edu/~ricel/
http://web.cse.ohio-state.edu/~ricel/
2
Common Functions
3
Round FunctionSyntax: =ROUND(number, num_digits)
number: Number to be rounded
num_digits: Number of decimal places
Round to: digit Formula Resultnearest whole number 0 =ROUND(2738.252,0) 2,738.000nearest tenth 1 =ROUND(2738.252,1) 2,738.300nearest hundreth 2 =ROUND(2738.252,2) 2,738.250
nearest tens -1 =ROUND(2738.252,-1) 2,740.000nearest hundreds -2 =ROUND(2738.252,-2) 2,700.000
4
5
Type in Function or use the Function Wizard
• Function wizard: A short-cut to all the functions in excel (use fx toolbar button) that walks you through building a function
6
Copying Formulas withRelative cell referencing
• Automatically adjusts formula cell references when formula is copied.
7
Copying Formulas withMixed cell referencing
Keeps the column or the row reference in the formula the same when copying the formula (Signified by $)
8
Copying Formulas withAbsolute cell referencing
Keeps the column and the row reference in the formula the same when copying the formula (Signified by $ in front of column and row)
9
Hard Coding values
Typing in the value in a formula or function instead of a cell reference• What if service charge changes to 8%?
10
Named Ranges
You can name a cell or a group of cells and use that name in your formulas.• Treated as an absolute cell reference
11
COUNTIF FUNCTION
Counts the number of items in a range that meet a specific criteria
=COUNTIF(range, criteria)
• Range: A continuous range• Criteria: Determines what cells to count
Criteria Criteria Syntax Example
Number Type in number =COUNTIF(C1:C10,5)
Text Surround text in quotes =COUNTIF(E1:E10,”USA”)
Cell Reference Type in cell reference =COUNTIF(G1:G10,A2)
“Hard Coded” Boolean Expression
Surround Boolean expression in quotes =COUNTIF(I1:I10,”>=5”)
Cell Reference Boolean Expression
Surround Boolean expression in quotes and type & before the cell reference
=COUNTIF(K1:K10, “>=” &A5)
Wild Card Use Asterisk =COUNTIF(M1:M10,”USA*”)
12
13
14
15
COUNTIFS FUNCTION
Counts the number of items in a range (using multiple criteria and multiple ranges) that meet a specific criteria
• All criterion must be true in order for the cell to be counted
=COUNTIFS(criteria_range1, criteria1,[criteria_range2,criteria2], …)
• Criteria_range1: A continuous range• Criteria1: Determines what cells to count
• Syntax rules the same as COUNTIF
16
17
SUMIF/AVERAGIF FUNCTIONS
Sums the number of items in a range that meet a specific criteria
=SUMIF(criteria_range, criteria,[sum_range])
Averages the number of items in a range that meet a specific criteria
=AVERAGEIF(criteria_range, criteria,[average_range])
• Criteria_Range: A continuous range• Criteria: Determines what cells to sum• Sum_Range: If criteria is met, the computer will sum the
corresponding entry in this range• Same criteria syntax as COUNTIF• If a sum_range argument is not used, the sum_range will be the same
as the criteria_range
18
19
20
SUMIFS/AVERAGEIFS FUNCTIONs
Sums a range (using multiple criteria and multiple ranges) that meet a specific criteria
• All criterion must be true in order for the cell to be summed
=SUMIFS(sum_range, criteria_range1,criteria1,[criteria_range2,criteria2], …)
Averages a range (using multiple criteria and multiple ranges) that meet a specific criteria
=AVERAGEIFS(average_range, criteria_range1,criteria1[criteria_range2,criteria2], …)
• Sum_Range: Range to sum if criterion are met• Criteria_Range1: Range of first criteria• Criteria1: Criteria for range1• Criteria syntax rules the same as COUNTIF
21
22
IF FUNCTION
Checks to see if a condition is true or false. If true one thing happens, if false another thing happens
• IF this is true, do this, else do this.
=IF(logical test, value_if_true, [value_if_false])
• Logical test must evaluate to true or false
23
24
NESTED IF
• IF this is true, do this, else IF this is true, do this, else, do this.
=if(this = true, do this, else if(this = true, do this, otherwise do this))
• Can be nested up to 64 times.
25
Assume no student has the same score.
26
IF with a range
27
Using Boolean functions
=AND(logical1, [logical2], …)• Returns true if all arguments evaluate to true
=OR(logical1, [logical2], …)• Returns true if at least one argument evaluates to true
=NOT(logical)• Changes false to true and true to false
28
Scores
Statistics
29
Write a formula in cell Statistics!F2 to determine T/F if everyone passed the class. (A passing score is 320)
=AND(Scores!E5>=Scores!B2,Scores!E6>=Scores!B2,Scores!E7>=Scores!B2)
30
Write a formula in cell Statistics!F3 to determine T/F if all the students are honors students.
31
Write a formula in cell Statistics!F4 to determine T/F if Led Zeppelin’s total score and Rob Thomas’ total score
is greater than Rascal Flat’s total score.
32
Write a formula in cell Statistics!F5 to determine T/F if as least one person passed the class.
=OR(Scores!E5>=Scores!B2,Scores!E6>=Scores!B2,Scores!E7>=Scores!B2)
33
Write a formula in cell Statistics!F6 to determine T/F if at least one person is an honors student.
34
Scores
New Stats
35
Write a formula in cell New Stats!F2 to determine if everyone passed the class. (A passing score is 320)
Display the text, “Everyone”, or “Not Everyone”
=IF(AND(Scores!E5>=Scores!B2,Scores!E6>=Scores!B2,Scores!E7>=Scores!B2),"Everyone", "Not Everyone")
36
Write a formula in cell New Stats!F3 to determine if all the students are honors students.
Display the text, “All Honor Students”, or “Not Everyone is an Honor’s student”
=IF(AND(Scores!F5:F7),"All Honor Students", "Not Everyone is an Honors student")
37
Write a formula in cell New Stats!F4 to determine if Led Zeppelin’s total score and Rob Thomas’ total score
is greater than Rascal Flat’s total score.Display the text, “Led and Rob”, or Rascal”
=IF(AND(Scores!E5>Scores!E7,Scores!E6>Scores!E7), "Led and Rob", "Rascal")
38
Write a formula in cell New Stats!F5 to determine if at least one person passed the class.
Display the text, “At least one passed” or “No One passed”
=IF(OR(Scores!E5>=Scores!B2,Scores!E6>=Scores!B2,Scores!E7>=Scores!B2),"At least one passed", "No One passed")
39
Write a formula in cell New Stats!F6 to determine if at least one person is an honors student.
Display the text, “At least one Honors student”, or “No Honor students”)
=IF(OR(Scores!F5:F7),"At least one Honors student", "No Honor students")
40
VLOOKUP/HLOOKUP
Finds an entry from a vertical array (table) based on a criteria
=VLOOKUP(lookup_value,table_array,col_index_num,[range_lookup])
Finds an entry from a horizontal array based on a criteria
=HLOOKUP(lookup_value,table_array,row_index_num,[range_lookup])
• lookup_value: criteria to lookup or “match”
• table_array: the range or boundary of your table (excluding headings)
• col_index_num: the column number in your range that contains the corresponding data
• range_lookup:– True: Finds the finds the closest value in your table array without going over– False: Finds an exact match in your table array
41
Grade Book
42
Write an excel formula in cell C7 that can be copied down the column to determine the student’s letter grade.
43
Write an excel formula in cell D7 that can be copied down the column to determine the student’s letter grade.
44
Write an excel formula in cell C7 that can be copied down the column to determine the student’s letter grade.
45
46CSE 2111 Lecture Iferror Function and
Examples
47
48
Write an excel formula in cell C6 that can be copied down the column to determine the new rent for the
corresponding rental property.
49
TABLE/ARRAY CREATIONRULES FOR LOOKUP RANGE: TRUE
TRUE• Leftmost column should contain the table range• Rightmost column should contain the value• Leftmost column must be in ascending order• Beginning value in table array must be the lowest
lookup value used in the lookup function