Formualizer Docs

IF

Returns one value when a condition is TRUE and another when FALSE.

IF(condition, value_if_true, [value_if_false]) supports two or three arguments.

The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.

Syntax

=IF(logical_test, value_if_true, [value_if_false])

Arguments

ArgumentTypeRequiredDefault
logical_testanyRequired—
value_if_trueanyRequired—
value_if_falseanyOptional—

Return type

Can return a reference when evaluated in a reference context.

Remarks

  • Condition coercion: booleans are used directly, numbers use 0 as FALSE and non-zero as TRUE.
  • A blank condition is treated as FALSE.
  • With only two arguments, the FALSE branch defaults to logical FALSE.
  • Array and range conditions select elementwise. Scalar branches and singleton axes broadcast; incompatible non-singleton dimensions return #VALUE!.
  • Each needed branch evaluates once; an unused branch is not evaluated and does not contribute to the result shape. Condition errors remain positional.
  • Generated arrays use the shared size cap (#NUM!); cancellation and resource failures abort evaluation rather than becoming array elements.

Error cases

  • Text or other non-numeric/non-boolean conditions return #VALUE!.

Examples

Choose between two text values with a numeric comparison.

Formula =IF(2>1,"Large","Small")

Expected result Large

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Omit the value for a false comparison.

Formula =IF(2>1,"Large")

Expected result Large

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Equal values make the strict greater-than comparison false.

Formula =IF(2>2,"Large","Small")

Expected result Small

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

The selected result expression divides by zero.

Formula =IF(2>1,1/0,0)

Expected result #DIV/0!

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Numeric condition

Formula =IF(2, "yes", "no")

Expected result yes

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Two-argument IF defaults false branch

Formula =IF(0, 10)

Expected result FALSE

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

FAQ

What is returned when IF has only two arguments and condition is FALSE?

The false branch defaults to logical FALSE when value_if_false is omitted.

Implementation

Engine source

On this page