Documentation/Calc Functions/IFS

Function name:
IFS

Category:
Logical

Summary:
From multiple conditions passed as arguments, determines the first condition that is met and returns the result that corresponds to that condition.

Syntax:
IFS(Expression 1; Result 1 [; Expression 2; Result 2][; ... ; [Expression 127; Result 127]])

Returns:
Returns a value whose type depends on the nature of the selected result argument.

Arguments:
Expression 1, Expression 2, ..., Expression 127 are expressions, or references to cells containing expressions, that that can be evaluated to a logical value TRUE or FALSE. If an expression is evaluated to a number instead of a logical value, then the value 0 (zero) is treated as FALSE, while any non-zero value is treated as TRUE. Any of Calc’s comparative operators = (equal), <> (inequality), > (greater than), >= (greater than or equal to), < (less than), and <= (less than or equal to) may be used to create conditions in the Expression n arguments. Each Expression n argument must have a corresponding Result n argument.

Result 1, Result 2, ..., Result 127 are expressions, or references to cells containing expressions, that give the results to be returned when the corresponding Expression n argument is the first to evaluate to TRUE.


 * If an Expression n argument cannot be evaluated as a logical value, then IFS reports a #VALUE! error.
 * If an Expression n argument is evaluated as the logical value TRUE but there is no corresponding Result n argument, then IFS reports a #N/A error.
 * If no Expression n argument is evaluated to TRUE, then IFS reports a #N/A error.

Details specific to IFS function

 * The IFS function can often be used as an easier-to-read alternative to creating a formula using multiple nested IF function calls.


 * Unlike the SWITCH function, IFS does not provide a "built-in" default value to use when all other expressions evaluate to false. However, to provide such a default value you can enter TRUE as the final expression, followed by a value to use as a default result.


 * The formula  is executed as described by the following pseudocode:


 * IF expression1 is TRUE
 * THEN result1
 * ELSE
 * IF expression2 is TRUE
 * THEN result2
 * ELSE
 * IF expression3 is TRUE
 * THEN result3


 * A consequence of this order of execution is that once IFS finds an Expression n argument that is true, it evaluates and returns the corresponding Result n argument, without processing any further expression or result arguments. For example, the formula  returns the string "First result" – while   might be expected to generate a #DIV0! error, the division is not attempted in this case.

Related LibreOffice functions:
AND

Special:MyLanguage/Documentation/Calc_Functions/FALSE

IF

IFERROR

IFNA

NOT

OR

SWITCH

Special:MyLanguage/Documentation/Calc_Functions/TRUE

XOR

ODF standard:
None.

Equivalent Excel functions:
IFS