Excel function

The IF function in Excel

IF checks a condition, then returns one value when it’s true and another when it’s false. It’s how a sheet makes decisions.

Syntax

=IF(logical_test, value_if_true, [value_if_false])
ArgumentWhat it does
logical_testA comparison that is either TRUE or FALSE, such as B2>=50.
value_if_trueWhat to show when the test is TRUE. Text goes in quotes: "Pass".
value_if_falseOptional. What to show when the test is FALSE. Leave it out and IF shows FALSE.

Here’s what that formula is doing.

=IF(B2>=50,"Pass","Fail") shows Pass for a score of 50 or more and Fail for anything lower. Filled down this column of scores, only Farah’s 47 fails.

Try it with real data.

Type a formula, then check it. Hints step in when you’re stuck, and the last one shows the answer.

Example data

Task 1

Delivery is free for orders of 100 or more, otherwise it costs 6.50. In C2, work out the delivery charge.

Example data for this task
ABC
1OrderTotalDelivery
2Order 104186.40 (answer cell)
Example data

Task 2

In C2:C9, show Pass for a score of 50 or more, otherwise Fail.

Write the formula for C2. We’ll fill it down to C9 for you.

Example data for this task
ABC
1StudentScoreResult
2Amara78 (answer cell)
3Ben64 (answer cell)
4Chen91 (answer cell)
5Dina55 (answer cell)
6Eli83 (answer cell)
7Farah47 (answer cell)
8Gus70 (answer cell)
9Hana88 (answer cell)

Common mistakes, and what our checker says.

Each message below is the checker’s real reply to that formula on the example data.

Text results without quotes

=IF(B2>=50,Pass,Fail)

The checker says: Text in a formula needs double quotes: "Pass".

Results that are text need quotes. Numbers don’t.

> instead of >=

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

The checker says: Check the boundary. Use >= so the value itself counts too. > leaves it out.

> leaves out 50 itself, so a score of exactly 50 would fail.

A missing third argument

=IF(B2>=50,"Pass")

The checker says: IF needs a third argument for when the test isn’t met. Without it, the cell shows FALSE.

Farah’s 47 shows FALSE instead of Fail.

A number in quotes

=IF(B2>=100,0,"6.50")

The checker says: Your formula returns the text "6.50", not a number. Numbers don’t need quotes in a formula.

In quotes, 6.50 becomes text, and SUM skips text, so totals come out wrong.

Questions

How do I check more than one condition?

Put AND or OR inside the test: =IF(AND(B2>=50,C2="Yes"),"Pass","Fail"). For three or more outcomes, nest IFs or use IFS.

Can IF leave a cell blank?

Use empty quotes: =IF(B2>=50,"Pass",""). The cell looks empty, though it holds empty text.

Does IF work with text?

Yes: =IF(D2="Yes","Paid","Due"). Text comparisons in Excel aren’t case-sensitive.

IF is part of module 5 of Excel Foundations: Make decisions.

Start practising now.

Excel Foundations is free, with no sign-up. Your progress is saved in this browser.