functions bus 782. types of functions built-in functions: –financial –date & time –math...
TRANSCRIPT
![Page 1: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/1.jpg)
Functions
BUS 782
![Page 2: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/2.jpg)
Types of Functions
• Built-in functions:– Financial– Date & time– Math & statistical– Database– Lookup– Logical– Information: IsBlank, IsNumber, IsText– Text– Etc.
• User-defined functions
![Page 3: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/3.jpg)
If Function
Determine action based on condition
![Page 4: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/4.jpg)
Examples
• Simple condition:– If total sales exceeds $300 then applies 5% discount;
otherwise, no discount.
• More than one condition:• Taxable Income < =3000 no tax• 3000 < taxable income <= 10000 5% tax• 10000 < taxable income <= 50000 10% tax• Taxable income > 50000 15% tax
• Complex condition:– If an applicant’s GPA > 3.0 and SAT > 1200: admitted
![Page 5: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/5.jpg)
Comparison• Less than: <• Less than or equal: <=• Greater than: >• Greater than or equal: >=• Equal: =• Not equal: <>
– At least: >=– At most: <=– No more than: <=– No less than: >=
• A comparison returns True/False.– Example:
![Page 6: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/6.jpg)
IF Function
• =IF(condition, ValueIfTrue,ValueIfFalse)
• Example: – Tuition: If total units <= 12, then tuition = 1200
» Otherwise, tuition = 1200 + 200 per additional unit
![Page 7: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/7.jpg)
• Example: Compute weekly wage. Overtime hours are paid 50% more than the regular pay.
![Page 8: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/8.jpg)
• Example: Tax rate is based on married status:– Single: 15%– Married: 10%
![Page 9: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/9.jpg)
• Example: A restaurant charges service fee based on this rule: 15% of the check amount with a minimum of $2.
![Page 10: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/10.jpg)
Exercises
• 1. How to determine an integer entered in a cell is an even number or an odd number?
• 2. The average of two exams is calculated by this rule: 60% * higher score + 40% * lower score.
• 3. An Internet service provider offers a service plan that charges customer based on this rule:
• The first 20 hours: $10• Each additional hour: $1.5
![Page 11: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/11.jpg)
Calculating Conditional Counts and Sums
• COUNTIF(range, criteria)– Range of cells– Criteria: expression that define which cells are
to be counted.
• SUMIF(range, criteria,[sum_range])– Sum_range: The cells you want to sum. If
omit, Excel will sum the values in the range argument.
![Page 12: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/12.jpg)
Example
1. How many employees earn more than 5000?
COUNTIF(B2:b4,”>5000”)
2. Compute the total salary of employees earning more than 5000.
SUMIF(B2:b4,”>5000”)
3. How many employees’ name begin with “P”?
COUNTIF(A2:A4,”P*”)
![Page 13: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/13.jpg)
Complex Condition
• Examples:– A theater charges admission fee based on
customer’s age:• 12 <= Age <= 65: Fee = $5• Otherwise: Fee = $3
– X University admission rules:• If GPA > 3.5 or SAT > 1500: Admitted
– Y University admission rules:• If GPA > 3.0 and SAT > 1200: Admitted
![Page 14: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/14.jpg)
Logical Operators: AND, OR, NOT
• AND• Cond1 Cond2 Cond1 AND Cond2
T TT FF TF F
• OR• Cond1 Cond2 Cond1 OR Cond2
T TT FF TF F
• NOT• Cond NOT Cond
TF
![Page 15: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/15.jpg)
Examples
• Write a complex condition for: 12 <= Age <= 65• Use a complex condition to describe age not
between 12 and 65.• X <= 15 is equivalent to: X<15 AND X =15?
(T/F)• This complex condition is always false:
– X < 5 AND X > 10
• This complex condition is always true:– X >= 5 OR X <= 10
![Page 16: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/16.jpg)
AND Function/OR Function
• =AND (cond1, cond2, …, cond n)– Up to 30 conditions– True if all conditions are true– False if any condition is false
• =OR (cond1, cond2, …, cond n)– True if any condition is true– False if all conditions are false
![Page 17: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/17.jpg)
![Page 18: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/18.jpg)
• The rules to compute employee bonus are: – If JobCode = 1 and Salary < 50000, then
bonus = 30% * salary– Otherwise, bonus = 20% * salary
Note: Change the rules to OR
![Page 19: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/19.jpg)
Nested IF and Complex Condition
![Page 20: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/20.jpg)
Nested IF
• Example:– Rules to determine bonus:
• JobCode = 1, Bonus=500• JobCode = 2, Bonus = 700• JobCode = 3, Bonus = 1000
– In C2: If(B2=1, 500, If(B2=2, 700, 1000))
![Page 21: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/21.jpg)
JobCode= 1
Or <> =1
JobCode=2 Or <> 2
1
2
3
![Page 22: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/22.jpg)
Example• Electric Company charges customers based on
KiloWatt-Hour used. The rules are:– First 100 KH, 20 cents per KH– Each of the next 200 KH
• (up to 300 KH), 15 cents per KH– All KH over 300, 10 cents per KH
![Page 23: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/23.jpg)
What if we have more than 3 conditions
• Example: Bonus– JobCode = 1, Bonus = 500– JobCode = 2, Bonus = 600– JobCode = 3, Bonus = 700– JobCode = 4, Bonus = 800– JobCode = 5, Bonus = 1000– …
• Other functions:– Table lookup
![Page 24: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/24.jpg)
Example
• State University calculates students tuition based on the following rules:– State residents:
• Total units taken <=12, tuition = 1200• Total units taken > 12, tuition = 1200 + 200 per
additional unit.
– Non residents:• Total units taken <= 9, tuition = 3000• Total units taken > 9, tuition = 3000 + 500 per
additional unit.
![Page 25: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/25.jpg)
Resident or Not
Units <= 12 or Not
Units <= 9 or Not
![Page 26: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/26.jpg)
Complex Condition
• University admission rules: Applicants will be admitted if meet one of the following rules:– 1. Income >= 100,000– 2. GPA > 2.5 AND SAT > 900
• An applicant’s Income is 150,000, GPA is 2.9 and SAT is 800. Admitted?– Income >= 100,000 OR GPA > 2.5 AND SAT >900
• How to evaluate this complex condition?
![Page 27: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/27.jpg)
• Scholarship: Business students with GPA at least 3.2 and major in Accounting or CIS qualified to apply:– 1. GPA >= 3.2– 2. Major in Accounting OR CIS
• Is a CIS student with GPA = 2.0 qualified?– GPA >= 3.2 AND Major = “Acct” OR Major = “CIS”
• Is this complex condition correct?
![Page 28: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/28.jpg)
NOTSet 1: Young: Age < 30
Set 2: Rich: Income >= 100,000
Young Rich
![Page 29: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/29.jpg)
Condition with Not
• University admission rules: Applicants will be admitted if meet all the rules:– 1. SAT > 900 OR Income >= 50,000– 2. Not GPA < 2.5
• Condition:– SAT > 900 OR Income >= 50,000 AND Not GPA < 2.5– Correct?
![Page 30: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/30.jpg)
Order of Evaluation
• 1. ()
• 2. Not
• 3. AND
• 4. OR
![Page 31: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/31.jpg)
Examples
• SAT = 800, Income 60,000, GPA 3.0, admitted?
– (SAT > 900 OR Income >= 50,000) AND Not GPA < 2.5
• A=2, B=3
– (A=3 OR NOT (B < A)) AND B=A+1
![Page 32: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/32.jpg)
• Rules to calculate employee bonus are:– If JobCode = 1 AND Salary < 5000 OR Sex = “F”
Bonus = 10% * Salary– Otherwise: Bonus = 8% * Salary
![Page 33: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/33.jpg)
Practices
• 1. Change the rules for bonus to:– If Sex = “F” AND (JobCode = 1 OR JobCode = 2)
then bonus = 10% * Salary– Otherwise, bonus = 8% * Salary
• 2. Change the rules to:– If JobCode = 1 AND Salary < 5000 OR Sex = “F”
Bonus = 10% * Salary– Otherwise: Bonus = 8% * Salary
• Use a complex condition to describe numbers:
20 50 100
![Page 34: Functions BUS 782. Types of Functions Built-in functions: –Financial –Date & time –Math & statistical –Database –Lookup –Logical –Information:IsBlank,](https://reader034.vdocument.in/reader034/viewer/2022051316/56649ec85503460f94bd5c96/html5/thumbnails/34.jpg)
Set 1: Young: Age < 30Set 2: Rich: Income >= 100,000 Set 3: Smart: GPA > 3.5
Young Rich
Smart