Excel functions / Logical

IF

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

Syntax=IF(logical_test, value_if_true, value_if_false)

Arguments

logical_testA comparison that is TRUE or FALSE, such as B2>=50.
value_if_trueWhat to show when the test is TRUE.
value_if_falseWhat to show when it is FALSE.

How it works

IF lets a spreadsheet make decisions: Pass or Fail, Paid or Overdue, a bonus or nothing. It checks the test and returns one of the two values.

Text results go in double quotes. The results can be numbers or formulas too: =IF(C2>1000,C2*0.1,0) pays a 10% bonus on sales over 1,000.

Example

E2=IF(B2>=50,"Pass","Fail")
ABCDE
1StudentScoreAttended
2Ana72YesPass
3Ben45Yes
4Cal88No
5

Result: Pass. Ana's 72 is at least 50.

Tips

Practise IF

Try it yourself in a real spreadsheet, with instant feedback on every answer.

Start the exercise

Related