Logical Functions
Logical Functions
• •
• The IF function is the key logical function used for decision making.
• It takes the format: =IF(condition, true, false)
• Purpose:
• Returns a value based on a condition.
• Syntax:
• =IF(logical_test, value_if_true, value_if_false)
• Example:
• =IF(A1 > 10, 'Yes', 'No') returns 'Yes' if A1 > 10, otherwise 'No'.
OR FUNCTION
• Sometimes the best way to get the result you need is to exclude the values
that you don’t want, rather than testing for the values that you do. The NOT
function is perfect for this situation, returning the logical opposite of the
condition test
• Purpose: Reverses the logical value.
• Syntax: =NOT(logical)
• Example: =NOT(A1 > 10) returns TRUE if A1 is not greater than 10.
• Daily Use: Exclude specific items, e.g., NOT marking 'Completed' tasks
IF WITH AND
• If both condition 1 and condition 2 evaluates to TRUE, then the value that
function returns is “YES”.
• If any of the conditions or every condition evaluates to FALSE, then the value that
function returns is “NO”.
If with OR
• To evaluate two or more conditions and return one result if any of the conditions
is TRUE, and another result if all the conditions are FALSE, embed the OR
function in the logical test of IF:
• IF(OR(condition1, condition2,...), value_if_true, value_if_false)
AND OR function