Menu Close

How to use the IF function in Excel?

What does the IF function do?

Before learning how to use the IF function in Excel let’s have a look at what it does. The IF function in Excel is used to perform logical tests and return different values based on whether the condition is TRUE or FALSE.

Why is the IF function useful?

The IF function is particularly useful for performing checks and automating data processing within datasets. Since the IF function can be nested, it allows for more complex conditions and returns the corresponding results.

Syntax

See below the correct syntax required to use the IF function in Excel:

=IF(logical_test, value_if_true, value_if_false)
  • logical_test: A condition that evaluates to TRUE or FALSE.
  • value_if_true: The result if the condition is TRUE.
  • value_if_false: The result if the condition is FALSE.

How to use the IF function in Excel

Examples of IF function usage

The IF function serves multiple purposes and can be applied in various ways. Below are different use cases, each with clear explanations and practical examples.

1. Basic IF Example: Pass or Fail

Let’s say we have student scores and want to determine whether they Passed (≥50) or Failed (<50).

ABC
1StudentScoreResult
2Alice85✅ Pass
3Bob40❌ Fail
4Charlie72✅ Pass
5David48❌ Fail
6Emma90✅ Pass

📌 Formula in Column C

=IF(B2>=50, "Pass", "Fail")

🚨 Result: If the score is 50 or more, it returns “Pass”; otherwise, it returns “Fail”.

2. IF with Multiple Conditions (Nested IF)

If we want to assign grades based on the score. Multiple verifications are required:

ABC
1StudentScoreGrade
2Alice85A
3Bob40F
4Charlie72B
5David48F
6Emma90A

📌 Formula

=IF(B2>=80, "A", IF(B2>=60, "B", IF(B2>=50, "C", "F")))

🚨 Breakdown:

  • If the score is 80 or more, return "A".
  • If the score is between 60 and 79, return "B".
  • If the score is between 50 and 59, return "C".
  • Otherwise, return "F".

3. IF with AND & OR (Multiple Conditions)

Example: Bonus Eligibility

To give a bonus, an employee must work for at least 5 years and have a performance score of 80 or more.

ABCD
1EmployeeYears of ServicePerformance ScoreBonus Eligibility
2Alice685✅ Yes
3Bob490❌ No
4Charlie778❌ No
5David582✅ Yes

📌 Formula Using AND

=IF(AND(B2>=5, C2>=80), "Yes", "No")

🚨 Explanation:

  • AND(B2>=5, C2>=80) ensures that both conditions must be met.
  • If both are TRUE, return "Yes", otherwise return "No".

Example: Discount Eligibility

A customer gets a discount if they spend $500 or more OR have been a customer for at least 3 years.

ABCD
1CustomerYears as CustomerAmount SpentDiscount?
2Alice2$600✅ Yes
3Bob4$450✅ Yes
4Charlie1$300❌ No
5David3$500✅ Yes

📌 Formula Using OR

=IF(OR(B2>=3, C2>=500), "Yes", "No")

🚨 Explanation:

  • OR(B2>=3, C2>=500) means that either condition can be true for a discount.
  • If at least one is met, return "Yes"; otherwise, return "No".

4. IF with Dates

Example: Check if a Deadline Has Passed

ABC
1TaskDeadlineStatus
2Report A01/15/2024🚩 Overdue
3Report B02/25/2024🕒 Upcoming
4Report C01/30/2024🚩 Overdue

📌 Formula

=IF(B2<TODAY(), "Overdue", "Upcoming")

🚨 Explanation:

  • TODAY() gets the current date.
  • If the deadline is before today, return "Overdue", otherwise "Upcoming".

5. IF with Blank Cells

Example: Check if a Cell is Empty

If B2 is blank, display "Missing Data", otherwise display "Complete".

ABC
1CustomerYears as CustomerResult
2Alice2✅ Complete
3Bob4✅ Complete
4Charlie❌Missing Data
5David3✅ Complete

📌 Formula

=IF(B2="", "Missing Data", "Complete")

Summary

As seen through the previous examples the IF function is versatile and has many use cases. It can be adapted depending on the situation to provide adequate results. Below are all the previous examples summarized in a table:

Use CaseFormula Example
Basic IF (Pass/Fail)=IF(B2>=50, "Pass", "Fail")
Nested IF (Grades)=IF(B2>=80, "A", IF(B2>=60, "B", IF(B2>=50, "C", "F")))
IF with AND (Bonus Eligibility)=IF(AND(B2>=5, C2>=80), "Yes", "No")
IF with OR (Discount Eligibility)=IF(OR(B2>=3, C2>=500), "Yes", "No")
IF with Dates (Deadline Check)=IF(B2<TODAY(), "Overdue", "Upcoming")
IF for Blank Cells=IF(B2="", "Missing Data", "Complete")

See also our products and tools

Gumroad Shop:

Leave a Reply

Your email address will not be published. Required fields are marked *