Introduction
The IF function in Excel is used to make decisions based on a condition. It checks whether a condition is TRUE or FALSE and returns one result when the condition is TRUE and another result when it is FALSE.
For example, an HR department can use the IF function to check whether an employee has passed a performance target. Similarly, teachers can use it to identify students who have passed or failed an examination.
In this tutorial, you will learn how to use the IF function in Excel with practical examples.
IF Function Syntax
=IF(logical_test, value_if_true, value_if_false)
Arguments:
- logical_test: The condition you want Excel to check.
- value_if_true: The result Excel returns when the condition is TRUE.
- value_if_false: The result Excel returns when the condition is FALSE.
Example:
=IF(A2>=40,"Pass","Fail")
If A2 contains 65, Excel returns Pass. If A2 contains 35, Excel returns Fail.
Question 1: Check Student Pass or Fail Status
Problem Statement:
A teacher wants to check whether students have passed or failed an examination. Students who score 40 or more marks are considered passed.
Use the IF function to display Pass or Fail.
Practical Data:
| Student Name | Marks |
|---|---|
| Amit | 78 |
| Priya | 35 |
| Rahul | 65 |
| Neha | 28 |
| Karan | 40 |
Assume student marks are in cells B2.
Excel Formula:
Enter this formula in C2:
=IF(B2>=40,"Pass","Fail")
Copy the formula down to C6.
Expected Result:
| Student Name | Marks | Result |
|---|---|---|
| Amit | 78 | Pass |
| Priya | 35 | Fail |
| Rahul | 65 | Pass |
| Neha | 28 | Fail |
| Karan | 40 | Pass |
Explanation:
The IF function checks whether the marks are greater than or equal to 40. If the condition is TRUE, Excel displays Pass. Otherwise, it displays Fail.
Question 2: Check Employee Salary Eligibility
Problem Statement:
An HR department wants to identify employees whose basic salary is ₹30,000 or more. Employees meeting this condition are marked Eligible, while others are marked Not Eligible.
Practical Data:
| Employee Name | Basic Salary |
|---|---|
| Amit | 25000 |
| Priya | 35000 |
| Rahul | 42000 |
| Neha | 28000 |
| Karan | 30000 |
Assume basic salaries are stored in B2.
Excel Formula:
=IF(B2>=30000,"Eligible","Not Eligible")
Enter the formula in C2 and copy it down.
Expected Result:
| Employee Name | Basic Salary | Eligibility |
|---|---|---|
| Amit | 25000 | Not Eligible |
| Priya | 35000 | Eligible |
| Rahul | 42000 | Eligible |
| Neha | 28000 | Not Eligible |
| Karan | 30000 | Eligible |
Explanation:
The formula checks whether the employee’s basic salary is at least ₹30,000. If it is, the result is Eligible. Otherwise, it displays Not Eligible.
Question 3: Check Employee Attendance Status
Problem Statement:
A company considers an employee present if their attendance is 22 days or more in a month.
Use the IF function to display Present or Low Attendance.
Practical Data:
| Employee Name | Attendance Days |
|---|---|
| Amit | 25 |
| Priya | 20 |
| Rahul | 23 |
| Neha | 18 |
| Karan | 22 |
Assume attendance days are stored in B2.
Excel Formula:
=IF(B2>=22,"Present","Low Attendance")
Enter the formula in C2 and copy it down.
Expected Result:
| Employee Name | Attendance Days | Attendance Status |
|---|---|---|
| Amit | 25 | Present |
| Priya | 20 | Low Attendance |
| Rahul | 23 | Present |
| Neha | 18 | Low Attendance |
| Karan | 22 | Present |
Explanation:
The formula checks whether attendance is 22 days or more. Employees meeting the condition receive the Present status.
Question 4: Check Sales Target Achievement
Problem Statement:
A company has assigned a monthly sales target of ₹100,000 to each salesperson.
If an employee achieves sales of ₹100,000 or more, display Target Achieved. Otherwise, display Target Not Achieved.
Practical Data:
| Salesperson | Monthly Sales |
|---|---|
| Amit | 120000 |
| Priya | 85000 |
| Rahul | 100000 |
| Neha | 95000 |
| Karan | 150000 |
Assume monthly sales are stored in B2.
Excel Formula:
=IF(B2>=100000,"Target Achieved","Target Not Achieved")
Enter the formula in C2 and copy it down.
Expected Result:
| Salesperson | Monthly Sales | Target Status |
|---|---|---|
| Amit | 120000 | Target Achieved |
| Priya | 85000 | Target Not Achieved |
| Rahul | 100000 | Target Achieved |
| Neha | 95000 | Target Not Achieved |
| Karan | 150000 | Target Achieved |
Explanation:
The IF function compares each salesperson’s monthly sales with the target of ₹100,000. Sales equal to or above the target are considered achieved.
Question 5: Check Product Stock Availability
Problem Statement:
A store manager wants to check whether products are available in stock.
If the stock quantity is greater than zero, display In Stock. If the quantity is zero, display Out of Stock.
Practical Data:
| Product Name | Stock Quantity |
|---|---|
| Keyboard | 25 |
| Mouse | 0 |
| Monitor | 12 |
| Printer | 0 |
| Laptop | 8 |
Assume stock quantities are stored in B2.
Excel Formula:
=IF(B2>0,"In Stock","Out of Stock")
Enter the formula in C2 and copy it down.
Expected Result:
| Product Name | Stock Quantity | Stock Status |
|---|---|---|
| Keyboard | 25 | In Stock |
| Mouse | 0 | Out of Stock |
| Monitor | 12 | In Stock |
| Printer | 0 | Out of Stock |
| Laptop | 8 | In Stock |
Explanation:
The formula checks whether the stock quantity is greater than zero. If products are available, Excel displays In Stock. Otherwise, it displays Out of Stock.
Question 6: Calculate Student Grades Using Nested IF
Problem Statement:
A school wants to assign grades to students based on their examination marks.
Use Nested IF to assign grades according to the following rules:
- Marks 90 or above: Grade A
- Marks 75 or above: Grade B
- Marks 60 or above: Grade C
- Marks 40 or above: Grade D
- Marks below 40: Fail
Practical Data:
| Student Name | Marks |
|---|---|
| Amit | 95 |
| Priya | 82 |
| Rahul | 68 |
| Neha | 45 |
| Karan | 30 |
Excel Formula:
=IF(B2>=90,"Grade A",IF(B2>=75,"Grade B",IF(B2>=60,"Grade C",IF(B2>=40,"Grade D","Fail"))))
Expected Result:
| Student Name | Marks | Grade |
|---|---|---|
| Amit | 95 | Grade A |
| Priya | 82 | Grade B |
| Rahul | 68 | Grade C |
| Neha | 45 | Grade D |
| Karan | 30 | Fail |
Explanation:
This formula uses multiple IF conditions inside one another. Excel checks each condition in order. When a condition becomes TRUE, it returns the corresponding grade.
Question 7: Check Employee Bonus Eligibility Using AND
Problem Statement:
A company provides a performance bonus only when an employee meets both conditions:
- Monthly sales must be ₹100,000 or more.
- Performance score must be 80 or more.
Use IF with AND to check bonus eligibility.
Practical Data:
| Employee Name | Monthly Sales | Performance Score |
|---|---|---|
| Amit | 120000 | 90 |
| Priya | 85000 | 85 |
| Rahul | 110000 | 75 |
| Neha | 150000 | 95 |
| Karan | 100000 | 80 |
Excel Formula:
=IF(AND(B2>=100000,C2>=80),"Bonus Eligible","Not Eligible")
Expected Result:
| Employee Name | Monthly Sales | Performance Score | Bonus Status |
|---|---|---|---|
| Amit | 120000 | 90 | Bonus Eligible |
| Priya | 85000 | 85 | Not Eligible |
| Rahul | 110000 | 75 | Not Eligible |
| Neha | 150000 | 95 | Bonus Eligible |
| Karan | 100000 | 80 | Bonus Eligible |
Explanation:
AND checks whether both conditions are TRUE. The IF function returns Bonus Eligible only when both requirements are satisfied.
Question 8: Check Employee Incentive Eligibility Using OR
Problem Statement:
A company offers a special incentive to employees who meet at least one of these conditions:
- Monthly sales are ₹150,000 or more.
- Performance score is 95 or more.
Use IF with OR to check incentive eligibility.
Practical Data:
| Employee Name | Monthly Sales | Performance Score |
|---|---|---|
| Amit | 160000 | 85 |
| Priya | 90000 | 96 |
| Rahul | 120000 | 80 |
| Neha | 150000 | 90 |
| Karan | 80000 | 95 |
Excel Formula:
=IF(OR(B2>=150000,C2>=95),"Incentive Eligible","Not Eligible")
Expected Result:
| Employee Name | Monthly Sales | Performance Score | Incentive Status |
|---|---|---|---|
| Amit | 160000 | 85 | Incentive Eligible |
| Priya | 90000 | 96 | Incentive Eligible |
| Rahul | 120000 | 80 | Not Eligible |
| Neha | 150000 | 90 | Incentive Eligible |
| Karan | 80000 | 95 | Incentive Eligible |
Explanation:
OR checks whether at least one condition is TRUE. If either sales or performance score meets the requirement, the employee becomes eligible.nction checks whether an employee has completed at least 6 months. If the condition is TRUE, the employee is marked Confirmed.
Question 9: Check Whether a Salesperson Has Exceeded the Target
Problem Statement:
A company has set a monthly sales target of ₹100,000. Management wants to identify salespeople who have exceeded the target, not just achieved it.
If sales are greater than ₹100,000, display Above Target. Otherwise, display Target Not Exceeded.
Practical Data:
| Salesperson | Monthly Sales |
|---|---|
| Amit | 125000 |
| Priya | 100000 |
| Rahul | 115000 |
| Neha | 90000 |
| Karan | 100000 |
Assume monthly sales are stored in B2.
Excel Formula:
=IF(B2>100000,"Above Target","Target Not Exceeded")
Enter the formula in C2 and copy it down.
Expected Result:
| Salesperson | Monthly Sales | Result |
|---|---|---|
| Amit | 125000 | Above Target |
| Priya | 100000 | Target Not Exceeded |
| Rahul | 115000 | Above Target |
| Neha | 90000 | Target Not Exceeded |
| Karan | 100000 | Target Not Exceeded |
Explanation:
The formula uses the greater-than (>) operator. Therefore, sales must be more than ₹100,000 to display Above Target. Sales equal to ₹100,000 do not meet this condition.
Question 10: Calculate Employee Incentive Based on Sales
Problem Statement:
A company provides a fixed incentive of ₹5,000 to sales employees who achieve monthly sales of ₹100,000 or more.
Use the IF function to calculate the incentive amount.
Practical Data:
| Employee Name | Monthly Sales |
|---|---|
| Amit | 125000 |
| Priya | 85000 |
| Rahul | 100000 |
| Neha | 95000 |
| Karan | 140000 |
Assume monthly sales are stored in B2.
Excel Formula:
=IF(B2>=100000,5000,0)
Enter the formula in C2 and copy it down.
Expected Result:
| Employee Name | Monthly Sales | Incentive |
|---|---|---|
| Amit | 125000 | 5000 |
| Priya | 85000 | 0 |
| Rahul | 100000 | 5000 |
| Neha | 95000 | 0 |
| Karan | 140000 | 5000 |
Explanation:
The IF function checks whether monthly sales are at least ₹100,000. If the condition is TRUE, Excel returns 5000. Otherwise, it returns 0.
Student Practice Tasks
Try these exercises yourself using the IF function.
Task 1: Student Result
A student passes if their marks are 35 or more. Display Pass or Fail.
| Student Name | Marks |
|---|---|
| Ankit | 45 |
| Simran | 30 |
| Mohit | 65 |
| Riya | 34 |
Task 2: Employee Leave Eligibility
An employee is eligible for a special leave benefit if they have completed at least 12 months in the company.
| Employee Name | Months Completed |
|---|---|
| Aman | 15 |
| Pooja | 8 |
| Varun | 12 |
| Meena | 10 |
Display Eligible or Not Eligible.
Task 3: Product Reorder Status
A product needs reordering when its stock quantity is less than 10.
| Product | Stock |
|---|---|
| Keyboard | 15 |
| Mouse | 5 |
| Monitor | 8 |
| Printer | 20 |
Display Reorder Required or Stock Sufficient.
Task 4: Sales Commission Eligibility
A salesperson receives a commission if monthly sales are greater than ₹75,000.
| Salesperson | Sales |
|---|---|
| Amit | 90000 |
| Priya | 70000 |
| Rahul | 75000 |
| Neha | 85000 |
Display Commission Eligible or Not Eligible.
Task 5: Check Minimum Order Amount
A company accepts free delivery for orders of ₹2,000 or more.
| Customer | Order Amount |
|---|---|
| Rohan | 2500 |
| Sneha | 1500 |
| Karan | 2000 |
| Pooja | 1800 |
Display Free Delivery or Delivery Charges Apply.
Final Student Challenge: Create an Employee Performance Report
Problem Statement:
You are working in the HR department of a company. Management wants an employee performance report based on monthly sales.
Use the IF function to calculate the incentive and display whether each employee has achieved the sales target.
Company Data:
| Employee ID | Employee Name | Monthly Sales |
|---|---|---|
| EMP801 | Amit Sharma | 125000 |
| EMP802 | Priya Verma | 85000 |
| EMP803 | Rahul Kumar | 110000 |
| EMP804 | Neha Singh | 95000 |
| EMP805 | Karan Gupta | 150000 |
| EMP806 | Pooja Mehta | 75000 |
Company Rules:
- Monthly sales target: ₹100,000.
- Incentive: ₹5,000 for employees achieving the target.
- Employees with sales below ₹100,000 receive no incentive.
Your Tasks:
- Display Target Achieved or Target Not Achieved.
- Calculate the employee incentive.
- Create a final report showing employee name, monthly sales, target status, and incentive.
Expected Result:
| Employee Name | Monthly Sales | Target Status | Incentive |
|---|---|---|---|
| Amit Sharma | 125000 | Target Achieved | 5000 |
| Priya Verma | 85000 | Target Not Achieved | 0 |
| Rahul Kumar | 110000 | Target Achieved | 5000 |
| Neha Singh | 95000 | Target Not Achieved | 0 |
| Karan Gupta | 150000 | Target Achieved | 5000 |
| Pooja Mehta | 75000 | Target Not Achieved | 0 |
Hint: Use one IF formula for the target status and another IF formula for the incentive amount.
Key Takeaways
- The IF function is a logical function in Excel.
- It checks whether a condition is TRUE or FALSE.
- It returns one result when the condition is TRUE and another when it is FALSE.
- The IF function uses three arguments: logical_test, value_if_true, and value_if_false.
- Comparison operators such as greater than, less than, and equal to can be used in the logical test.
- IF can return text, numbers, or calculated results.
- It is useful for employee reports, student results, sales targets, attendance, and payment tracking.
Frequently Asked Questions (FAQs)
1. What is the IF function in Excel?
The IF function checks a condition and returns one value if the condition is TRUE and another value if it is FALSE.
2. What is the syntax of the IF function?
The syntax is:
=IF(logical_test, value_if_true, value_if_false)
3. Can the IF function return text?
Yes. The IF function can return text such as Pass, Fail, Eligible, Not Eligible, Yes, or No. Text results must be enclosed in double quotation marks.
4. Can the IF function return numbers?
Yes. The IF function can return numbers such as 0, 100, or 5000 depending on the condition.
5. What happens if the IF condition is FALSE?
Excel returns the value specified in the third argument, value_if_false.
6. Can I use greater than or less than operators inside IF?
Yes. You can use comparison operators such as >, <, >=, <=, =, and <> inside the logical_test argument.
7. Can the IF function compare two cells?
Yes. For example:
=IF(A2>=B2,"Achieved","Not Achieved")
This compares the values in A2 and B2.
8. Can the IF function be used to calculate bonuses?
Yes. You can use IF to calculate bonuses, incentives, commissions, and other amounts based on conditions.
9. Can the IF function check text values?
Yes. For example:
=IF(A2="Paid","Completed","Pending")
This checks whether cell A2 contains the text Paid.
10. Is the IF function case-sensitive?
No. A standard IF text comparison is not case-sensitive. For example, Paid and PAID are treated as equal in a normal comparison.

