Conditional Functions
Conditional Functions
Examples:
There are six types of conditional functions covered by this course. Each has
a specific use and syntax.
AND and OR
=AND(condition1, [condition2], …)
=OR(condition1, [condition2], …)
For example,
=AND(G2=”BLAH”,A2=”OCHO”)
will evaluate to TRUE if the cell G2 is “BLAH” and the cell A2 is “OCHO”.
For example,
=OR(E2>12,F2<54)
IF
=if(condition,value_if_true,value_if_false)
If the given condition is true, the cell will be set to the “value_if_true.” If the
condition is false, the cell will be set to the “value_if_false.” The “value_if_true”
and “value_if_false” are optional inputs which default to TRUE and FALSE,
respectively.
Example:
Reads: If A2>3 is true, then set the cell to 32. Otherwise, set the cell to
“Number too small”
Nested IF Functions
You can nest one “if” function inside of another to test for multiple conditions
at once. A single “if” function, without the use of any other functions, can only
test for a single condition.
Example:
Test the condition of whether the contents of cell A2 are between 10 and 20.
The completed function will test whether the value of A2 is larger than 20. If it
is, the active cell will be set to “Number too large.” If A2 is less than 20, it will
be tested to see if the value of A2 is less than 10. If it is, the active cell is set
to “Number too small.” Otherwise, we know that the value of A2 must be
between 10 and 20, so the active cell is set to “Just right!”
COUNTIF
=countif(range,criteria)
The “countif” function will increment the active cell by one each time the
criteria is true for a cell in the given range.
Example:
You want to know how many universities have “red” as one of their school
colors, and have compiled a database of schools and their colors in Excel.
If a cell in F1:F230 satisfies “=red”, then increment the active cell by one.