IF Function and Nested IF Function of Excel 6
IF Function and Nested IF Function of Excel 6
1. Introduction to IF Functions
What is an IF Function?
The IF function is a logical function that checks whether a condition is met, returning one value for a TRUE
result and another for a FALSE result. The syntax is:
IF Syntax:
=IF(logical_test, value_if_true, value_if_false)
o IF(F2 >= 80, "B": If the average score is 80 to 89, return "B".
o IF(F2 >= 70, "C": If the average score is 70 to 79, return "C".
o IF(F2 >= 60, "D": If the average score is 60 to 69, return "D".
o If none of these conditions are met, return "F".
3. Drag Down:
o Drag the formula down from cell G2 to apply to all students.
Result Interpretation
The final grades will now be categorized as:
o A: 90 and above
o B: 80 to 89
o C: 70 to 79
o D: 60 to 69
o F: below 60
3. Practical Example
Complete Steps in Excel
1. Enter Data: Input the sample dataset into an Excel worksheet.
2. Calculate Average Score:
o In cell F2, enter =AVERAGE(C2:E2) and drag down.
3. Apply Nested IF for Final Grades:
o In cell G2, enter the nested IF formula:
=IF(F2 >= 90, "A", IF(F2 >= 80, "B", IF(F2 >= 70, "C", IF(F2 >= 60, "D", "F"))))
o Drag the formula down from G2 to apply to all rows.
Example Output for Final Grades
Student Employee Math Science English Average Final
ID Name Score Score Score Score Grade
001 ANUP 85 92 78 85.00 B
002 BUBUN 72 85 90 82.33 B
003 AKASH 60 75 65 66.67 D
004 SWAPAN 95 88 91 91.33 A
005 LALIT 55 62 58 58.33 F
006 WASIM 70 70 75 71.67 C
007 KAJAL 88 84 80 84.00 B
008 GOUTAM 95 95 92 94.00 A
009 RAHUL 45 50 55 50.00 F
010 MOU 82 78 88 82.67 B
Practice Activities
STUDY / PRACTICE NOTES FOR SESSION 10, 11 & 12
1. Modify Conditions: Change the score thresholds in the nested IF formula to create different
grading systems.
2. Create Additional Conditions: Add more conditions to categorize performance further (e.g., plus
and minus grades).
3. Explore Other Functions: Combine IF statements with other functions, such as COUNTIF or SUMIF,
for enhanced analysis.
The IF function is one of the most powerful functions in Excel, allowing users to perform logical tests and
return different results based on the outcome. By combining the IF function with the AND or OR
functions, you can add multiple conditions to your logic.
2. IF with AND
The AND function is used when you want multiple conditions to be true at the same time. All conditions
must be true for the AND function to return TRUE.
Let's assume we have a dataset where we track the performance of students in two subjects
(Math and English). We want to classify students as "Eligible" for a scholarship only if they score
above 70 in both subjects.
Dataset:
Student Name Math Score English Score Scholarship Eligibility
John 75 80
Mary 65 85
Alice 90 60
Bob 80 72
Formula in Column "Scholarship Eligibility":
excel
Copy code
=IF(AND(B2 > 70, C2 > 70), "Eligible", "Not Eligible")
Explanation:
o B2 > 70: Checks if the Math score is greater than 70.
o C2 > 70: Checks if the English score is greater than 70.
STUDY / PRACTICE NOTES FOR SESSION 10, 11 & 12
o If both conditions are true (i.e., the student scored above 70 in both subjects), the
formula returns "Eligible". Otherwise, it returns "Not Eligible".
Result:
Student Name Math Score English Score Scholarship Eligibility
John 75 80 Eligible
Mary 65 85 Not Eligible
Alice 90 60 Not Eligible
Bob 80 72 Eligible
3. IF with OR
The OR function is used when you want any one of several conditions to be true. If any of the conditions
are true, the OR function will return TRUE.
Using the same dataset of students, suppose we want to label students as "Pass" if they score
above 70 in either Math or English.
Explanation:
o B2 > 70: Checks if the Math score is greater than 70.
o C2 > 70: Checks if the English score is greater than 70.
o If either of these conditions is true, the formula returns "Pass". If neither condition is
true, it returns "Fail".
Result:
Student Name Math Score English Score Pass/Fail
John 75 80 Pass
Mary 65 85 Pass
Alice 90 60 Pass
Bob 80 72 Pass
Example Returns TRUE only if A1 and B1 are both Returns TRUE if either A1 or B1 is
Result greater than 50. greater than 50.
5. Practical Applications
IF with AND is useful when you need to check for multiple criteria that must all be met.
Examples include:
o Determining if an employee qualifies for a bonus based on meeting sales targets and
attendance records.
o Checking whether a product meets quality standards by passing several tests.
IF with OR is useful when you need to check if one or more criteria are met. Examples include:
o Passing a student who meets the required score in either of two exams.
o Approving a loan application if the applicant has either a high income or a strong credit
score.
6. Key Takeaways