Google Sheets Function: IF

The IF function allows displaying one of two values based on a condition.

Usage:

=IF(logical_expression, value_if_true, value_if_false)


Example of use

A common use of the IF function is to test if a cell is empty before displaying a result.

In this example, the total should only be calculated and displayed if the quantity is entered:

=IF(B2<>"",B2*C2, "")
google sheets function if non empty
If needed, you can copy the Google Sheets document (or view the document) with this example.

Very detailed explanations

To better understand how to use the IF function (and functions in general), see the IF function page of the Google Sheets course.

A second example with nested IF functions is also available.