Excel function

IFfunction

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

All versions
=IF(B2>=60, "Pass", "Fail")
A
B
C
D
E
1
2
3
4
5
6
7

Click a cell in the table to change cell to test. Column E shows the same formula copied down. Change the threshold to 80 and see how each row changes. Try breaking it on purpose to see the errors.

Result

Pass

cell to test
B2You can also click a cell in the table

The cell the condition checks. Click a score in the sheet.

comparison

How to compare the cell with the threshold.

threshold

The value to compare against.

value_if_true

Returned when the condition is TRUE.

value_if_false

Returned when the condition is FALSE. If empty, IF returns FALSE.

What is the IF function?

=IF(logical_test, value_if_true, [value_if_false])

IF checks a condition and returns one value when it is TRUE and another when it is FALSE. It is the basic building block for pass/fail labels, bonuses, flags and status columns.

The condition is usually a comparison such as B2>=60. Text results must be in double quotes, like "Pass".

Arguments

logical_test
A comparison that is either TRUE or FALSE, such as B2>=60 or A2="Seoul".
value_if_true
What to return when the test is TRUE. It can be a number, text in quotes, or another formula.
value_if_false
What to return when the test is FALSE. If omitted, IF returns FALSE.

IF examples

  1. Example 1. Pass or fail

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

    B2 is 85, which is 60 or more, so the result is Pass.

  2. Example 2. Leave a blank instead

    =IF(B2>=90, "Top", "")

    Two double quotes with nothing between them return empty text, so only top scores are labeled.

  3. Example 3. More than two outcomes

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

    An IF inside another IF checks the next condition only when the first is FALSE. For many bands, IFS or a lookup table is easier to read.

Common mistakes

FAQ

How do I check two conditions at once?
Use AND or OR inside the test, for example IF(AND(B2>=60, C2>=60), "Pass", "Fail").
What does IF return if value_if_false is left out?
It returns FALSE when the test is FALSE.