Download presentation
Presentation is loading. Please wait.
Published byGiana Foulkes Modified over 9 years ago
2
# 1# 1 CS 105 Functions, IF Functions What is a function? What is an IF function? A PMT function? What is a condition? What is nesting? CS 105 Spring 2010
3
# 2# 2 Functions An Excel command that does a specific task Here’s a common function in Excel: SUM(A2:B5) This function’s task: sum all cell values described within the parentheses (here, the range A2:B5) –the answer is called the function’s return value Why functions? Define once, use many times –simply change the stuff within parentheses –called the arguments of the function
4
# 3# 3 CS 105 Spring 2010 Arguments A function has a name and arguments Arguments can be data, cell names/ranges or other functions Examples: SQRT (9) one argument AVERAGE (A3, A5, A7) three arguments SUM (A1:A10, Totals) two arguments (a range and the name of a range)
5
# 4# 4 CS 105 Spring 2010 Built-in functions Excel comes pre-loaded with many useful functions Categories include: –Math & Trige.g., SQRT, ABS, COUNT, COUNTA,… –Statisticale.g., AVG –Financiale.g. PMT –Text e.g. CONCATENATE Later, we will see how to write our own functions to extend Excel’s “toolkit” or “library”
6
# 5# 5 CS 105 Spring 2010 PMT function PMT function requires interest rate/period, number of payments, and amount of loan Establish PMT –Amount of loan –Down payment –Interest rate/12 –Term (in months)
7
# 6# 6 CS 105 Spring 2010 As in…
8
# 7# 7 CS 105 Spring 2010 Note: Watch out! Repayment is by default from the bank’s point of view (returns a negative number, and we want a positive number). In order to find our payment, we make the final number negative
9
# 8# 8 Quiz on PMT Say the interest on a car is 18% a year. In calculating the interest PER MONTH you: A.Pay 18% interest each month B.Pay 18% divided by 12 C.Pay 18% multiplied by 12 CS 105 Spring 2010
10
# 9# 9 Using Goal Seek I want to pay only $200 a month. What car can I afford? –Change payment total by changing one of the above variables –The top value must have a formula in it –Goal: $200 –Computer calculates the value of the car you can afford Data Tab in Excel 2007
11
# 10 Suppose we want formula #1 under some conditions, and a different formula #2 under other conditions Example: How does the ABS function work? ABS(A5) = A5if A5 >= 0, but ABS(A5) = -A5if A5 < 0 Visually: CS 105 Spring 2010 IF: adding power to functions True A5 >= 0 If False A5 -A5
12
# 11 CS 105 Spring 2010 The IF function Apply formula #1 (after first comma) True Apply formula #2 (after second comma) Condition If False
13
# 12 CS 105 Spring 2010 How the IF function works: eg, single IF statement looks like this: IF(A2>90, “A”, “B”) IF (logical test, value if true, value if false) Note: string data in a formula must be surrounded by “ ”, why?
14
# 13 CS 105 Spring 2010 Commission example If TEESALES sells $100,000 worth of tee shirts, the sales commission rate will be 6%. If the sales total is less than $100,000, the rate will be only 5%. Finding the Commission for sales >= $100,000, pay 6% of sales for sales < $100000, pay 5% of sales
15
# 14 CS 105 Spring 2010 Example IF function wizard An IF function tests for a condition You can type the IF function directly in the formula box or use the dialog box of the IF Function
16
# 15 CS 105 Spring 2010 Example of IF =IF(B3>=100000,.06*B3,.05* B3) B3>=100000?.06*B3 TRUE.05*B3 FALSE
17
# 16 CS 105 Spring 2010 Nested IFs If TEESALES sells $100,000 worth of tee shirts, the sales commission rate will be 6%. If the sales total is equal to or more than $80,000, but less than $100,000, the rate will be 5%. If total sales are below $80,000, the rate will be 3.5% of sales.
18
# 17 CS 105 Spring 2010 Example 2 of IF B3>=100000?.06*B3.035* B3 TRUE FALSE? Then another test....05*B3 TRUEFALSE =IF( B3>=100000,.06*B3, IF(B3>=80000,.05*B3,.035*B3) ) B3>=80000?
19
# 18 CS 105 Spring 2010 Practice with Relational Operators A1 = B1 -- FALSE A1 <> B1-- TRUE A1 = B2 -- FALSE A1 < B1 -- TRUE A1 < B2-- TRUE A1 = A2-- TRUE A1 >= A2-- TRUE A2 > B2-- FALSE
20
# 19 CS 105 Spring 2010 AND, OR, NOT Functions Formula view Output of formulas:
21
# 20 CS 105 Spring 2010 COUNTIF Function Syntax: COUNTIF(Range, Criteria) Can be used on a summary worksheet, as in lab Download employee.xls to practice this
22
# 21 CS 105 Spring 2010 SUMIF Function The SUMIF function adds figures to a total only if they match a certain criterion The syntax is SUMIF( range, criteria to check, range where numbers are)
23
# 22 Text Functions Concatenation (putting two words together) Concatenation can be done by a function –e.g. =CONCATENATE(B3,C4) Operands can be : – character strings: “Tarzan” & “Jane” – cell addresses containing text values: B3 Concatenation can also be done by using an operator & e.g. = B3 & C4 CS 105 Spring 2009
24
# 23 Adding a space Strings in formulas must always appear in quotes in Excel. To add a space, just put it between quotes. Remember, there is an ASCII value for a space! You can also put a space between the quote and the start of Water CS 105 Spring 2009
25
# 24 CS 105 Spring 2010 To Summarize What is a function? What is an IF function? A PMT function? What is a condition? What is nesting?
26
# 25 Figuring out monthly interest The answer is that you take the annual interest rate and divide it by 12, the number of months CS 105 Spring 2010
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.