An “if” statement evaluates a cell based on a condition.

=IF(logical test, [value if true], [value if false])

Note that the argument for logical test can be a single cell or a data array. value if true and value if false must be single values, but they can be strings (e.g. “TRUE” or “FALSE”) or numbers (e.g. 0 or 1).

Entering conditions

Suppose you want to check if cell A2 is equal to zero. If it passes the test, the function returns “TRUE”, otherwise return “FALSE”:

=IF(A2=2, "TRUE", "FALSE")

Now suppose you want to check if the cell is greater than zero, and this time if it passes the test, return the number 1, return “:(“:

=IF(A2>0, 1, ":(")

If you wanted to run the same test, but this time checking if A2 $\geq 0$:

=IF(A2>=0, 1, ":(")

Demo