Skip to main content

IF

The IF function returns the second argument if a condition is met, and the third one otherwise.

This is one of the most frequently used functions for creating conditions and managing data in spreadsheets.

Syntax​

IF(logical_test, value_if_true, [value_if_false])

ArgumentDescriptionPermitted values
logical_testA Boolean expression that needs to be checked to see if it's trueBoolean condition or expression, or reference to a cell that contains the logical value TRUE or FALSE
value_if_trueThe value returned by the function if the “logical_test” argument is TRUEAny value (number, text, and so forth)
[value_if_false](optional) The value returned by the function if the “logical_test” argument is FALSEAny value (number, text, and so forth)

Examples of use​

Use with numbers

=IF(A1 > 10, "Greater than 10", "10 or less")

If the value in cell A1 is greater than 10, the function will return “Greater than 10”; otherwise, it will return “10 or less.”

Use with text

=IF(B1 = "Yes", "Agree", "Disagree")

If cell B1 contains “Yes,” the function will return “Agree,” otherwise it will return “Disagree.”

Nested functions

=IF(A1 > 10, "Greater than 10", IF(A1 = 10, "Equal to 10", "Less than 10"))

This formula checks several conditions: if A1 is greater than 10, it returns “Greater than 10”; if it is equal to 10, it returns “Equal to 10”; otherwise, it returns “Less than 10.”

Notes​

  • The IF function can be used in combination with other functions to create more complex Boolean expressions.
  • To improve the readability of formulas and reduce errors, you can use nested functions.
  • Pay attention to the order of the arguments value_if_true and value_if_false when writing the function.