Logic

Google Sheets IF Function — Syntax, Examples & Tips

Learn how to use the IF function in Google Sheets with practical examples. Nested IF, IF with AND/OR, and common mistakes explained.

Syntax
=IF(condition, value_if_true, value_if_false)

What IF Does

The IF function checks whether a condition is true or false and returns one value for true and another for false. It is the foundation of decision-making in Google Sheets, letting you automate labels, flags, and calculations based on your data. Almost every spreadsheet workflow uses IF at some point.

Syntax

=IF(condition, value_if_true, value_if_false)
ParameterDescription
conditionA logical test that evaluates to TRUE or FALSE (e.g., A1 > 100).
value_if_trueThe value returned when the condition is TRUE. Can be text, a number, or another formula.
value_if_falseThe value returned when the condition is FALSE. Optional — defaults to FALSE if omitted.

Basic Examples

Example 1: Pass or Fail

You have student scores in column B and want to mark whether each student passed (score >= 60).

ABC (Formula)C (Result)
1NameScoreStatusStatus
2Emma78=IF(B2>=60,"Pass","Fail")Pass
3Jake45=IF(B3>=60,"Pass","Fail")Fail

Example 2: Bonus Eligibility

Sales reps earning over $10,000 in revenue get a bonus flag.

ABC (Formula)C (Result)
1RepRevenueBonus?Bonus?
2Sarah12500=IF(B2>10000,"Yes","No")Yes
3Tom8200=IF(B3>10000,"Yes","No")No

Example 3: Stock Alert

Flag items where inventory drops below the reorder point.

ABC (Formula)C (Result)
1ProductQtyAlertAlert
2Widget A5=IF(B2<10,"Reorder","OK")Reorder
3Widget B42=IF(B3<10,"Reorder","OK")OK

Advanced Examples

Nested IF — Assigning Letter Grades

When you need more than two outcomes, nest IF functions inside each other.

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

For a score of 85, this returns "B". The formula checks each threshold from highest to lowest and stops at the first match.

IF with AND/OR — Multi-Condition Check

A sales lead qualifies only if the deal size is over $5,000 AND the lead source is "Inbound."

=IF(AND(B2>5000, C2="Inbound"), "Qualified", "Nurture")

To qualify if either condition is met, swap AND for OR:

=IF(OR(B2>5000, C2="Inbound"), "Qualified", "Nurture")

Common Mistakes

  • Forgetting quotes around text values. =IF(A1>5, Yes, No) throws an error. Text must be wrapped in double quotes: "Yes" and "No".
  • Nesting too many IFs. Deeply nested IF formulas become unreadable. If you have more than 3-4 levels, consider using IFS or SWITCH instead.
  • Comparing text without matching case. =IF(A1="yes",...) won't match "YES" or "Yes". Use =IF(LOWER(A1)="yes",...) to handle mixed case.

SheetAI Tip

Don't want to memorize this syntax? With SheetAI, just type what you need in plain English — like "if sales > 1000, mark as High Priority" — and the formula is generated for you. Install SheetAI to try it free.

Skip the formula. Describe what you need.

SheetAI lets you type what you want in plain English and generates the perfect formula — no syntax to memorize.

Try SheetAI Free