The IF function in Excel is a powerful tool used for decision-making. It evaluates conditions and then returns one value if a condition is true, and another value if the condition is false. In this article, we will show how to apply Excel’s IF function in complex real-life scenarios with practical examples. You often need to use the IF function in complex situations that require multiple conditions or calculations.
Basic Syntax of the IF Function
The basic syntax of the IF function is:
=IF(logical_test, value_if_true, value_if_false)
- logical_test: The logical test to evaluate.
- value_if_true: The result to return if the condition is true.
- value_if_false: The result to return if the condition is false.
You can use the following logical operators to construct a logical test in Excel:
- = (equal to)
- > (greater than)
- >= (greater than or equal to)
- < (less than)
- <= (less than or equal to)
- <> (not equal to)
Scenario 1: Bonus Calculation Based on Performance
Consider a scenario where you have a list of employees with their performance scores, and you want to calculate a bonus based on their performance. Employees with a score of 80 or higher get a 10% bonus, while those below 80 get a 5% bonus.
- Insert the following formula in the selected cell.
- Drag down the formula to calculate the bonus of each employee.
Formula:
=IF(B2>=80, C2*10%, C2*5%)
- B2>=80: It is a logical test to check performance scores.
- If true, it calculates C2*10% (10% of salary).
- If false, it calculates C2*5% (5% of salary).
Output:
Scenario 2: Grade Performance Based on Score (Nested IF)
You can grade employees based on performance scores or you can assign grades to students based on their marks. The grading system for schools can be as follows:
The performance score grading can be as follows:
- 90+: Excellent
- 80-89: Good
- 70-79: Average
- Below 70: Needs Improvement
You can nest multiple IF functions to cover all grading criteria. Insert the following formula in the selected cell.
Formula:
=IF(B2>=90, "Excellent", IF(B2>=80, "Good", IF(B2>=70, "Average", " Needs Improvement")))
Each IF checks a score range, returns the matching status, and stops when a condition is met. This approach lets you assign performance levels automatically, making it easy to evaluate large datasets quickly.
Output:
Scenario 3: Calculate Bonus Based on Multiple Criteria (AND/OR)
In some cases, you need to evaluate multiple conditions at once. You can combine IF with AND or OR functions to combine multiple criteria. A bonus is awarded if both sales exceed $70,000, and the employee’s performance rating is Excellent or Good.
Formula:
=IF(AND(D2>=70000, OR(F2="Excellent", F2="Good")), C2*15%, C2*5%)
- AND(D2>=70000, OR(F2=”Excellent”, F2=”Good”)): Checks if the sales amount in D2 is 70,000 or more and if the performance in F2 is either “Excellent” or “Good”.
- C2*15%: If both conditions are met, a 15% bonus is calculated based on the value in C2.
- C2*5%: If the conditions aren’t met, it will return a 5% bonus.
Output:
Scenario 4: Nested IF for Complex Financial Calculations
Consider a scenario where you need to calculate tax for employees based on income brackets.
- Salary below $5000: 10% tax.
- Salary between $5000 and $10000: 15% tax.
- Salary above $10000: 20% tax.
Formula:
=IF(C2<=5000, C2*10%, IF(C2<=10000, C2*15%, C2*20%))
- First checks if the income is below $5000 (10% tax).
- Then it will check if it’s between $5000 and $10000 (15% tax).
- If neither, will apply a 20% tax.
Output:
Scenario 5: Overtime Calculation for Working Hours
Suppose you want to calculate the overtime bonus of employees. An employee earns a bonus if they work more than 40 hours a week. If their total hours exceed 40, they get $20 per extra hour worked.
Formula:
=IF(B2>40, (B2-40)*20, 0)
- Condition check if hours worked are greater than 40.
- If it is true, calculate the bonus for extra hours worked.
Output:
Scenario 6: Grade Management Using Dynamic IF Function
The IF function is the most useful for assigning grades to students based on their marks.
The grading system can be as follows:
- 90+ marks: A+
- 80-89 marks: A
- 70-89 marks: B
- 60-69 marks: C
- Below 60: Fail
To get the individual grade use the following formula.
Regular Formula:
=IF(B2>=90,"A+",IF(B2>=80,"A",IF(B2>=70,"B",IF(B2>=60,"C","Fail"))))
This formula evaluates each cell in the range individually and then assigns grades based on the logic.
Dynamic Array Formula:
=IF(B2:D7>=90,"A+",IF(B2:D7>=80,"A",IF(B2:D7>=70,"B",IF(B2:D7>=60,"C","Fail"))))
- This formula in a cell (e.g., E2), Excel will automatically apply the grading logic to each cell in the B2 range and “spill” the results into adjacent cells.
- Each cell in B2 is evaluated, and the correct grade (“A+”, “A”, “B”, “C”, or “Fail”) is displayed based on the score.
Output:
To get the average grade of each student, insert the following formula.
Dynamic Array Formula:
=IF(E2:E7>=90,"A+",IF(E2:E7>=80,"A",IF(E2:E7>=70,"B",IF(E2:E7>=60,"C","Fail"))))
This formula spills results automatically for each score in E2. Assigns “A+”, “A”, “B”, “C”, or “Fail” based on the score range.
Output:
This array formula will only work in versions with dynamic array support (like Excel 365).
Conclusion
The IF function in Excel is essential for making decisions and performing calculations based on different criteria. By nesting IF functions, using logical operators like AND/OR, and combining them with other functions, you can solve complex real-life problems in Excel. This article explained multiple scenarios including dynamic array formulas. Practice and apply these scenarios to get more comfortable with the flexibility and power of the IF function.
Get FREE Advanced Excel Exercises with Solutions!