IFS (Condition, ThenValue, OtherCondition..., OtherThenValue...) IFS (Condition; ThenValue; OtherCondition...; OtherThenValue...)

Condition

Logical Logical

The condition to check.

ThenValue

The value to return if the condition is TRUE.

OtherCondition

Logical Logical (accepts many)

An additional condition to check.

OtherThenValue

An additional value to return if the preceding condition is TRUE.

Returns

The value associated with the first condition which is TRUE (evaluated from left to right). If no condition is TRUE, a blank value is returned.

Returns one of the given values based on logical conditions. IFS (Value1 > 20, 2, Value2 > 40, 4, TRUE, 6) IFS (Value1 > 20; 2; Value2 > 40; 4; TRUE; 6) returns 2 if Value1 has a value greater than 20, 4 if Value1 does not have a value greater than 20 and Value2 has a value greater than 40, and 6 otherwise.

IFS is mostly identical to IF, with the sole difference being that IFS does not support a fallback value, that is, a value that is returned if no condition evaluates to TRUE. As such, the equivalent to IF (Value1 > 20, 2, Value2 > 40, 4, 6) IF (Value1 > 20; 2; Value2 > 40; 4; 6) is IFS (Value1 > 20, 2, Value2 > 40, 4, TRUE, 6) IFS (Value1 > 20; 2; Value2 > 40; 4; TRUE; 6) — note that the final condition is TRUE, enabling a fallback value to be used with IFS.

IFS is provided for compatibility with spreadsheets. Use the plain IF function if spreadsheet-compatibility is not a concern. Also, refer to the documentation for IF for an extended discussion and many more examples.

Examples

IFS (TRUE, 2, TRUE, 4)
IFS (TRUE; 2; TRUE; 4)

Returns 2.

IFS (FALSE, 2, TRUE, 4)
IFS (FALSE; 2; TRUE; 4)

Returns 4.

IFS (Value1 > 20, 2, Value2 > 40, 4, TRUE, 6)
IFS (Value1 > 20; 2; Value2 > 40; 4; TRUE; 6)

Returns 2 if Value1 is greater than 20, 4 if Value1 is not greater than 20 and Value2 is greater than 40, and 6 otherwise.

fxEngine Shell Want this in your own terminal? A standalone version is coming. Get notified.
Loading fxEngine Shell