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

IF Function and Nested IF Function of Excel 6

Uploaded by

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

IF Function and Nested IF Function of Excel 6

Uploaded by

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

STUDY / PRACTICE NOTES FOR SESSION 10, 11 & 12

IF Functions and Nested IF Statements

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)

Example of Basic IF Function


Let’s determine if a student has passed or failed based on their average score.
1. Calculate Average Score:
o In cell F2, enter the formula to calculate the average of Math, Science, and English scores:
=AVERAGE(C2:E2)
2. Determine Pass/Fail:
o In cell G2 (Final Grade), enter the following IF function:
=IF(F2 >= 60, "Pass", "Fail")
3. Drag Down:
o Drag the formula down from cell G2 to apply to all students.
Result Interpretation
 Students with an average score of 60 or above will display "Pass", while those below will show
"Fail".

2. Using Nested IF Statements


What are Nested IF Statements?
Nested IF statements are used when you need to evaluate multiple conditions. The syntax allows you to
place one IF function inside another.
Nested IF Syntax:
=IF(logical_test1, value_if_true1, IF(logical_test2, value_if_true2, value_if_false))

Example: Grade Classification


Let’s classify the final grades into letter grades (A, B, C, D, F) based on average scores.
1. Modify the Final Grade Column:
o In cell G2, replace the previous formula with a nested IF statement:
=IF(F2 >= 90, "A", IF(F2 >= 80, "B", IF(F2 >= 70, "C", IF(F2 >= 60, "D", "F"))))
2. Breakdown of the Formula:
o IF(F2 >= 90, "A": If the average score is 90 or above, return "A".
STUDY / PRACTICE NOTES FOR SESSION 10, 11 & 12

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.

"IF with AND" & "IF with OR" Functions in Excel

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.

1. Basic Structure of the IF Function

 Formula: =IF(logical_test, value_if_true, value_if_false)


 Example: =IF(A1 > 50, "Pass", "Fail") returns "Pass" if the value in cell A1 is greater than 50,
otherwise it returns "Fail".

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.

 Formula: =IF(AND(condition1, condition2, ...), value_if_true, value_if_false)


 Use case example:

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.

 Formula: =IF(OR(condition1, condition2, ...), value_if_true, value_if_false)


 Use case example:

Using the same dataset of students, suppose we want to label students as "Pass" if they score
above 70 in either Math or English.

Formula in Column "Pass/Fail":


excel
Copy code
=IF(OR(B2 > 70, C2 > 70), "Pass", "Fail")

 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

4. Comparison of "IF with AND" and "IF with OR"

Feature IF with AND IF with OR


Condition All conditions must be true. At least one condition must be true.
Logic
Example =IF(AND(A1>50, B1>50), "True", "False") =IF(OR(A1>50, B1>50), "True",
Formula "False")
STUDY / PRACTICE NOTES FOR SESSION 10, 11 & 12

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

 IF with AND requires all conditions to be met.


 IF with OR requires at least one condition to be met.
 These functions help in decision-making processes by automating logical comparisons across
datasets.

You might also like