SpreadJS Documentation
IF
SpreadJS Documentation > Formula Reference > Formula Functions > IF

This function performs a comparison and returns one of two provided values based on that comparison.

Syntax

IF(valueTest,valueTrue,valueFalse)

Arguments

This function has these arguments:

Argument Description
valueTest Value or expression to evaluate
valueTrue Value to return if the test evaluates to true
valueFalse Value to return if the test evaluates to false

Remarks

The value of valueTest is evaluated. If it is non-zero (or TRUE), then valueTrue is returned. If it is zero (or FALSE), then valueFalse is returned. The value of valueTest must be or evaluate to numeric data, where non-zero values indicate TRUE, and a value of zero indicates FALSE. It may contain one of the relational operators: greater than (>), less than (<), equal to (=), or not equal to (<>).

Data Types

Accepts numeric (boolean) data. Returns any data type.

Example

IF(A3<>2000,1900,2000)

IF(R1C2>65,1000,2000)

IF(C4,B2,B4)

IF(1>2,5,10) gives the result 10

IF(1<2,""dogs"",""cats"") gives the result dogs

See Also