ExcelTool.io

IF

Returns one value when a condition is true and another when it is false.

Syntax

=IF(logical_test, value_if_true, value_if_false)

Arguments

  • logical_test - Any expression that evaluates to TRUE or FALSE, e.g. A1>100.
  • value_if_true - What to return when the test is true.
  • value_if_false - What to return when the test is false.

Examples

=IF(A1>=50, "Pass", "Fail")

Returns: "Pass" when A1 is 50 or more

The classic threshold test.

=IF(A1="", "", A1*1.2)

Returns: Blank when A1 is empty, otherwise A1 × 1.2

Guarding against blank inputs keeps columns clean.

Common Errors and Gotchas

  • Text results must be quoted; cell references and numbers must not.
  • Deeply nested IFs get unreadable fast - consider IFS or a lookup table.

Does IF Work in Google Sheets?

Yes. IF uses the same syntax in Google Sheets and LibreOffice Calc, so you can paste these formulas straight across.

See Also