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

Lecture 05 - If Function

The document provides an overview of the IF function in Excel, detailing its use for logical evaluations and decision-making based on conditions. It includes examples of basic and nested IF functions, as well as combining IF with AND, OR, and NOT functions, alongside error handling with IFERROR. Additionally, it covers COUNTIF and SUMIF functions for counting and summing based on conditions, and presents practical exercises for applying these concepts.

Uploaded by

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

Lecture 05 - If Function

The document provides an overview of the IF function in Excel, detailing its use for logical evaluations and decision-making based on conditions. It includes examples of basic and nested IF functions, as well as combining IF with AND, OR, and NOT functions, alongside error handling with IFERROR. Additionally, it covers COUNTIF and SUMIF functions for counting and summing based on conditions, and presents practical exercises for applying these concepts.

Uploaded by

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

IF

Function
Discussion

• Logical functions in Excel allow you to make


decisions based on conditions.
• The IF function is the most commonly used logical
function, and it can be combined with other logical
functions like AND, OR, NOT, IFERROR, and IFS to
perform more complex evaluations.
Basic IF
Function
The IF function evaluates a condition and
returns different values depending on
whether the condition is TRUE or FALSE.
Basic IF Function
• =IF(logical_test, value_if_true, value_if_false)

• logical_test → The condition to test (e.g., A1>50).


• value_if_true → The result if the condition is TRUE.
• value_if_false → The result if the condition is FALSE.
Example: Checking if a student has
passed or failed
• =IF(B2>=75, "Pass", "Fail")

• If B2 (student's score) is 75 or above, the function returns "Pass".


• Otherwise, it returns "Fail".
Nested IF
(Multiple
Conditions)
When you have more than two possible
outcomes, you can use multiple IF
functions inside each other.
Nested IF: Grading System
• =IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "F")))

• If B2 ≥ 90, the grade is "A".


• If B2 is between 80-89, the grade is "B".
• If B2 is between 70-79, the grade is "C".
• Otherwise, the student gets "F".
Nested IF: Grading System
• Alternative: Use the IFS function (simplifies multiple conditions).
• =IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", B2<70, "F")

• Easier to read than nested IFs!


Combining IF
with AND & OR
Nested IF: Grading System
• =IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "F")))

• If B2 ≥ 90, the grade is "A".


• If B2 is between 80-89, the grade is "B".
• If B2 is between 70-79, the grade is "C".
• Otherwise, the student gets "F".
AND Function
• Returns TRUE if all conditions are met, otherwise FALSE.
• Example: If a student passed both Math and Science, mark as
"Eligible“.
• =IF(AND(B2>=75, C2>=75), "Eligible", "Not Eligible")
• If both B2 and C2 are ≥75, return "Eligible"
• Otherwise, return "Not Eligible"
OR Function
• Returns TRUE if at least one condition is met.
• Example: If a student passed either Math or Science, mark as
"Qualified“
• =IF(OR(B2>=75, C2>=75), "Qualified", "Not Qualified")
• If B2 or C2 is ≥75, return "Qualified".
• If both are below 75, return "Not Qualified".
Using NOT
Function
(Reversing
Logic)
NOT Function
• The NOT function reverses a condition. If the condition is TRUE, it
becomes FALSE, and vice versa.
• Example: If a student did not pass (score <75), mark as “Review”
• =IF(NOT(B2>=75), "Review", "Good Job")
• If B2 is below 75, return "Review".
• If B2 is 75 or above, return "Good Job".
Handling Errors with IFERROR
• The IFERROR function prevents errors by returning a custom message
when an error occurs.
• Example: Preventing division errors
• =IFERROR(A2/B2, "Invalid")
• If B2 is 0, instead of showing #DIV/0!, it returns "Invalid".
COUNTIF –
Counting Based
on a Condition
COUNTIF
• The COUNTIF function counts the number of cells that meet a specific
condition.
• =COUNTIF(range, criteria)
• range → The range of cells to check.
• criteria → The condition to count.
COUNTIF
• Example: Count Students Who Passed
• If a student passes with a grade of 75 or above, count how many
passed.
• =COUNTIF(B2:B20, ">=75")
• Counts all students with scores 75 and above.
SUMIF –
Summing Based
on a Condition
SUMIF
• The SUMIF function adds up values that meet a specific condition.
• =SUMIF(range, criteria, sum_range)
• range → The range to evaluate.
• criteria → The condition.
• sum_range → The actual values to sum.
SUMIF
• Example: Total Sales of a Product
• If we want to sum the sales only for Product A, use:
• =SUMIF(A2:A20, "Product A", B2:B20)
• Adds up all sales for Product A.
COUNTIF with IF
• Example: Check If a Student is in the Top 3
• If the student’s rank is in the Top 3, return "Top Performer".
• Otherwise, return "Keep Improving".
• =IF(COUNTIF(B2:B20, "<=3")>0, "Top Performer", "Keep Improving")
• If a student's rank (Column B) is ≤3, they get "Top Performer".
SUMIF with IF
• Example: Bonus Eligibility Based on Sales**
• If total sales ≥100,000, bonus = "Eligible".
• Otherwise, "Not Eligible".
• =IF(SUMIF(A2:A20, "John", B2:B20)>=100000, "Eligible", "Not
Eligible")
• If John’s total sales ≥100,000, return "Eligible".
Combining SUMIF with COUNTIF
• Example: Performance Review (Sales and Count Criteria)**
• If an employee made at least 5 sales AND total sales are ≥50,000,
return "Good Performer".
• Otherwise, return "Needs Improvement".
• =IF(AND(COUNTIF(A2:A20, "John")>=5, SUMIF(A2:A20, "John",
B2:B20)>=50000), "Good Performer", "Needs Improvement")
• If John made at least 5 sales and total sales ≥50,000, he is a
"Good Performer".
COUNTIFS and SUMIFS – Multiple
Conditions
• COUNTIFS – Counting with Multiple Conditions
• =COUNTIFS(A2:A20, "IT Department", B2:B20, ">=80")
• Counts how many IT department employees scored 80 or above.
COUNTIFS and SUMIFS – Multiple
Conditions
• SUMIFS – Summing with Multiple Conditions
• =SUMIFS(C2:C20, A2:A20, "Electronics", B2:B20, ">=10")
• Sums total revenue from Electronics where sales ≥10 units.
Practical Exercises

• Exercise 1: Employee Bonus


Calculation
• If sales ≥ 50,000, bonus =
"₱10,000"
• If sales ≥ 30,000 but <50,000,
bonus = "₱5,000"
• Otherwise, "No Bonus"
Practical Exercises

• Exercise 2: Loan Eligibility Check


• If Salary ≥ 30,000 and No
Existing Loans, eligible =
"Approved"
• Otherwise, "Denied"
Practical Exercises

Exercise 3: Count Employees with High


Sales
Task: Count how many sales transactions
are ≥50,000.
=COUNTIF(C2:C12, ">=50000")
Exercise 4: Total Revenue
for a Specific Product
Task: Sum the sales for
"Laptop" only.
=SUMIF(B2:B12,
"Laptop", C2:C12)

Practical Exercises
Practical Exercises

Exercise 5: Check Employee Incentives


Task: If John's total sales are ≥75,000
and he made at least 3 sales, he qualifies
for an incentive.
=IF(AND(SUMIF(A2:A12, E7,
C2:C12)>=75000, COUNTIF(A2:A12,
E7)>=3), "Incentive Granted", "No
Incentive")
Thank you

You might also like