IF

Choose between two results depending on whether a condition is true.

Syntax

IF(logical_test, value_if_true, [value_if_false])
Argument Required Description
logical_test Required Anything that evaluates to TRUE or FALSE.
value_if_true Required What to return when the test passes.
value_if_false Optional What to return when it fails. Omitted, you get FALSE.

Examples

Every example below was executed against VisiGrid engine 0.35.0 — not transcribed from another vendor's documentation. Reproduce any of them with vgrid calc.

Formula Result Notes
=IF(A1>5,"big","small") big
=IF(1>2,"y","n") n
=IF(A1>5,"big") big
=IF(A1<5,"small") FALSE Omitting the third argument returns FALSE, not blank — rarely what anyone wants.

Always give the third argument

Leaving it off does not produce an empty cell. It produces the word FALSE, which then flows into whatever reads that cell and turns arithmetic into #VALUE! further down. If you want blank, say so:

=IF(A1<5, "small", "")

Nesting, and when to stop

Two or three levels is readable. Beyond that, IF inside IF inside IF becomes a puzzle, and IFS says the same thing as a flat list of conditions. For matching one value against several fixed options, SWITCH is shorter still.

A common mistake is using IF to catch errors — IF(ISERROR(x), 0, x) evaluates x twice. IFERROR evaluates it once, and IFNA is narrower again.

Excel compatibility

Matches Excel, including returning FALSE when value_if_false is omitted.

Related functions

Last updated