IF

Function Reference: IF

Syntax
=IF(logical_test,[value_if_true],[value_if_false])
Purpose / Description
Returns one of two possible results, conditional upon the value of the first argument. Used for the simplest conditional logic where there are only two possible outcomes.
Arguments
logical_test logical A constant, reference or expression that indicates which of the two values passed as value_if_true or value_if_false is returned as the function’s result.
[value_if_true] any An optional constant, reference or expression that derives the value returned if the value of logical_test is TRUE. If omitted the value returned will be the number value .
[value_if_false] any An optional constant, reference or expression that derives the value returned if the value of logical_test is FALSE. If omitted the value returned will be the logical value FALSE.
Return Values
any   If logical_test is TRUE, returns the value of the value_if_true argument otherwise, returns the value of the value_if_false argument.  Can return all value types and range references.
error #VALUE! If the value type of logical_test is not a logical value and cannot be coerced to a logical value.
error   Any errors referenced by arguments are returned due to propagation of error values.
Notes / Comments / Advice / Warnings
Comment: Although value_if_true and value_if_false are both shown as optional, only one may be omitted. The omission of an argument in an IF function can’t be properly justified in a worksheet setting. The option to omit was provided for its use in the old XLM macro language.
Advice: IF functions usually have logical expressions nested, such as comparing a cell to a value or calculated value, such as A1<=10. Sometimes, those nested logical expressions can be needlessly complex or lead to enormous redundancy in calculation . Consider increasing transparency by use of logical expressions independently of IF functions.
Advice: There is a tendency to overuse nesting of IF functions. Our recommendation is broadly, no more than two IF functions in a single formula, if it seems more are required, there is a more effective approach. Consider IFS, SWITCH or CHOOSE for a handful of conditions. Consider a lookup or reference where there are many conditions.