Skip to content
Klargrid

The IF function

The decision function: if the condition is true, one value; otherwise, another. Things get complicated when they are nested.

Syntax

=IF(logical_test, value_if_true, [value_if_false])

In a French Excel: =SI(test_logique; valeur_si_vrai; [valeur_si_faux]).

Arguments

  • logical_test: a comparison that is TRUE or FALSE, such as B2>1000.
  • value_if_true: what to return if it is true.
  • value_if_false: what to return otherwise; omitted, IF returns FALSE.

An example

=IF(AND(B2>=1000,C2="Delivered"),"Bonus","")

Returns "Bonus" if the amount reaches 1,000 and the order is delivered; an empty cell otherwise. AND requires both conditions, OR would settle for one.

Pitfalls

  • Text without quotes: =IF(C2=Delivered,…) returns #NAME?.
  • Nested IFs beyond three are hard to read: IFS or a lookup table are safer.
  • Comparing a number and text: "1000" as text is not greater than 999.

Going further

Frequently asked questions

How many IFs can be nested?
Up to 64, but beyond three the formula becomes hard to read and fix: IFS or a lookup table with XLOOKUP are safer.