I was trying the other day to use conditional statements in Excel, but was getting an error message. I did not want write a VBA-code for a simple task.
I wanted to calculate the score of Exam 2 for a student who had perfect attendance, a score of 90 or above in homework assignments, and a score of 90 or above in Exam 1. My policy this semester is that such a student can skip exam 2.
How I solved the problem?
First, I wrote one single IF statement for condition 1, which is the score in exam 1 as follows,
Let me denote the first IF statement as X1.
Second, I added a second IF statement to X1 conditional on class attendance as follows,
Third, I added a third IF statement to X2 conditional on the assignment score as follows,
In this way "IF" statements can be nested almost endlessly.
The key in nesting IF is to make sure that the structure of an IF statement is respected,
I wanted to calculate the score of Exam 2 for a student who had perfect attendance, a score of 90 or above in homework assignments, and a score of 90 or above in Exam 1. My policy this semester is that such a student can skip exam 2.
How I solved the problem?
First, I wrote one single IF statement for condition 1, which is the score in exam 1 as follows,
=IF(D3>=90,D3,($E$54-25)*$E$55),
where D3 is the cell where the score of exam 1 is for student i, and the expression ($E$54-25)*$E$55 is an expression to calculate the score for an exam with 25 questions. I will note this expression as C.Let me denote the first IF statement as X1.
Second, I added a second IF statement to X1 conditional on class attendance as follows,
=IF(Attendance!E2="YES",X1,C),
where Attendance! is the name of a sheet. Let me denote the second IF statement as X2.Third, I added a third IF statement to X2 conditional on the assignment score as follows,
=IF(Assigment!C2>=90,X2,C).
The key in nesting IF is to make sure that the structure of an IF statement is respected,
=IF(condition,command,clearance)
=IF(A>B,A,B),
which means if A is greater than B, then A, else B.
No comments:
Post a Comment