180 likes | 329 Views
Conditional Logic Using Excel “IF” Statements. Some “plain-English” examples of conditional logic statements. My grading scale—(yours might be different). Example 1: A simple conditional logic test
E N D
Some “plain-English” examples of conditional logic statements
Example 1: A simple conditional logic test Based on the grading scale shown in the previous slide, create a conditional logic statement that determines if each of the values in column K (“Pct of Tot Pts Possible”) represents a passing grade (“Pass”) or a failing grade (“Fail”), and store the results in column M ( “Pass or “Fail”).
The basic form of an “If” statement is: =IF(Logical Test is True,Then,Else)
The conditional logic statement for the first case is: =IF(K2>=59.5,“Pass","Fail")
The conditional logic statements for all cases are: For the value in K2 (i.e., 73), the conditional logic statement would be: =IF(K2>=59.5,”Pass”,”Fail”) For the value in K3 (i.e., 89.6), the conditional logic statement would be: =IF(K3>=59.5,”Pass”,”Fail”) For the value in K4 (i.e., 59.4), the conditional logic statement would be: =IF(K4>=59.5,”Pass”,”Fail”) For the value in K5 (i.e., 79.8), the conditional logic statement would be: =IF(K5>=59.5,”Pass”,”Fail”) For the value in K6 (i.e., 67.2), the conditional logic statement would be: =IF(K6>=59.5,”Pass”,”Fail”)
Example 2: “Nested” conditional logic tests Based on the grading scale shown previously, create a conditional logic statement that will determine the letter grade for each of the values in column K (“Pct of Tot Pts Possible”), and store the results in column L (“Ltr Grade”).
The conditional logic statement for the first case is: =IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F")))) Displayed on the next four slides are its four ”nested” component parts…
=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F"))))=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F"))))
=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F“))))=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F“))))
=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F“))))=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F“))))
=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F"))))=IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F"))))
The conditional logic statements for all cases are: For the value in K2 (i.e., 73), the conditional logic statement would be: =IF(K2>=89.5,"A",IF(K2>=79.5,"B",IF(K2>=69.5,"C",IF(K2>=59.5,"D","F")))) For the value in K3 (i.e., 89.6), the conditional logic statement would be: =IF(K3>=89.5,"A",IF(K3>=79.5,"B",IF(K3>=69.5,"C",IF(K3>=59.5,"D","F")))) For the value in K4 (i.e., 59.4), the conditional logic statement would be: =IF(K4>=89.5,"A",IF(K4>=79.5,"B",IF(K4>=69.5,"C",IF(K4>=59.5,"D","F")))) For the value in K5 (i.e., 79.8), the conditional logic statement would be: =IF(K5>=89.5,"A",IF(K5>=79.5,"B",IF(K5>=69.5,"C",IF(K5>=59.5,"D","F")))) For the value in K6 (i.e., 67.2), the conditional logic statement would be: =IF(K6>=89.5,"A",IF(K6>=79.5,"B",IF(K6>=69.5,"C",IF(K6>=59.5,"D","F"))))
Some Important Things to Remember About Nested Conditional Logic Statements: • You are limited to a maximum of 7 logical tests when creating nested conditional logic statements. • Separate the 3 parameters for each conditional logic statement with commas. • For each conditional logic statement, you must enclose its parameters inside a separate set of parenthesis. • For each conditional logic statement, if the “then” and “else” parameters are fixed characters (like letters or numbers), enclose them in a pair of double quotes (i.e., “).