Skip to main content
SheetCraft
🔀 Logical Function · beginner

IF Function in Google Sheets

Returns one value when a condition is true and a different value when false. The foundation of conditional logic in spreadsheets and the most-used Google Sheets function after SUM.

Syntax

IF(logical_expression, value_if_true, value_if_false)

Returns: Either value_if_true or value_if_false depending on the condition.

Excel equivalent: IF (identical)

Parameters

NameRequiredDescription
logical_expressionRequiredA comparison that evaluates to TRUE or FALSE.
value_if_trueRequiredWhat to return when logical_expression is TRUE.
value_if_falseRequiredWhat to return when logical_expression is FALSE.

Examples

Pass/fail by score

=IF(B2 >= 70, "Pass", "Fail")

Returns "Pass" when B2 is 70 or above, "Fail" otherwise.

Discount only for premium customers

=IF(D2 = "Premium", C2 * 0.9, C2)

Applies a 10% discount when the customer type in D2 is Premium, otherwise returns the original price in C2 unchanged.

Nested IF for letter grades

=IF(B2 >= 90, "A", IF(B2 >= 80, "B", IF(B2 >= 70, "C", "F")))

Nested IF works but gets unwieldy fast. For more than 2-3 branches, use IFS instead — same result with much cleaner syntax.

When to use an alternative

  • IFSYou have 3 or more conditions to check in sequence.
  • SWITCHYou're comparing one value against a fixed list of possibilities.
  • IFERRORYour condition is specifically "did this formula error?"

Common errors and how to fix them

  • Comma-vs-semicolon confusion

    Cause: Some locales use semicolons as argument separators.

    Fix: Use commas in en-US locale. Check Spreadsheet settings if formulas fail to parse.

  • Quotes around numbers

    Cause: Wrapping a number in quotes makes it a string: IF(A2 = "5", ...) won't match the number 5.

    Fix: Drop quotes when comparing numbers. Only use quotes for text values.

  • Missing third argument

    Cause: IF requires all three arguments in Google Sheets.

    Fix: Always supply value_if_false — use IFERROR if you want to silently return blank on a missing condition.

Related functions

Frequently Asked Questions

Can IF return a formula instead of a value?

Yes. value_if_true and value_if_false can be any expression — IF(A2>100, SUM(B:B), AVERAGE(B:B)) is valid. Each branch only evaluates when its condition is met.

What's the maximum nesting depth for IF?

Google Sheets allows about 64 nested function calls. For practical purposes, more than 3 nested IFs becomes unreadable — switch to IFS or a lookup table at that point.

Source: Google Sheets official function reference.