FormulaCamp
Completed
← All functions
Logic

IF

Chooses between two outcomes based on a condition.

Syntax

IF(logical_test, [value_if_true], [value_if_false])

Example: =IF(B2>=60,"Pass","Fail")

Available in: All versions

IF tests a condition and returns one value when it is true and another when it is false: =IF(condition, value_if_true, value_if_false). It is the building block of almost every decision in a spreadsheet, such as pass or fail, late or on time, discount or none.

When to use it

Arguments explained

Worked examples

Pass or fail

AB
1StudentScore
2Ana72

Formula: D2: =IF(B2>=70,"Pass","Fail")

Result: Pass

72 is at least 70, so the true branch is returned. Text results go in quotes.

Nested IF for letter grades

AB
1StudentScore
2Ben84

Formula: D2: =IF(B2>=90,"A",IF(B2>=80,"B","C"))

Result: B

The second IF sits in the false branch of the first. For more than three outcomes prefer IFS.

Two conditions with AND

ABC
1NameAgeMember
2Cara21Yes

Formula: E2: =IF(AND(B2>=18,C2="Yes"),"Eligible","Not eligible")

Result: Eligible

AND is true only when both tests are true. Use OR when one is enough.

Try it

A tiny spreadsheet with example data. Edit the formula or any number and see the result.

Formula in F2: =IF(B2>=60,"Pass","Fail")

Example spreadsheet for IF
ABCDEF
1StudentScoreExtra creditAttemptsResult
2Ann92Yes2Pass
3Bob74No0
4Cy58Yes3
5Dee81No1
6Eli662
Result in F2: Pass
Practice this in a lesson: Nested IF and IFS

Common errors and how to fix them

Related functions

Frequently asked questions

How do I use IF with multiple conditions?
Combine tests with AND (all must be true) or OR (any can be true) inside the first argument, or nest further IFs, or use IFS.
How many IFs can I nest?
Excel allows 64 levels, but readability breaks down after three or four. Use IFS, SWITCH or a lookup.
Can IF return a blank?
Yes, use two double quotes: =IF(A1="","",A1*2).
Is IF case sensitive when comparing text?
No. "yes" equals "YES" in an IF comparison.

Practice

More in Logic