IF function in Excel: examples and practice

IF tests a condition and gives back one value if it is true and another value if it is false. For example, =IF(B2>=100,"Free delivery","Delivery fee") checks the order total in B2.

Syntax

=IF(logical_test, value_if_true, [value_if_false])
logical_test
The condition, for example B2>=100. It is TRUE or FALSE.
value_if_true
The result when the condition is TRUE. Put text in quotes.
value_if_false
Optional. The result when the condition is FALSE. Without it, you get FALSE.

Examples

Example data

AB
1OrderTotal
2A10145
3A102120
4A10380
5A104150
FormulaResultWhat it does
=IF(B2>=100,"Free delivery","Delivery fee")Delivery fee45 is less than 100, so the test is FALSE.
=IF(B3>=100,"Free delivery","Delivery fee")Free delivery120 is 100 or more, so the test is TRUE.
=IF(B4>=100,0,5)5IF can also give back numbers. Here it gives the delivery fee.

Try it

In cell D5, show "Free" when the total in B5 is 100 or more. Else show "Fee".

Show the solution

=IF(B5>=100,"Free","Fee") → Free

Common mistakes

Text without quotes

=IF(B2>=100,Yes,No) gives #NAME?. Excel reads Yes as a name. Write "Yes" and "No" in quotes.

Numbers in quotes

=IF(B2>="100",...) compares with the text 100, not the number. Write numbers without quotes.

> instead of >=

B2>100 is FALSE for exactly 100. Use >= when the limit itself counts.

Priya Nair, runs Lantern Fest, a small music festival

Practice this in a story

A short lesson from a real job. We show you each step, then you do it yourself.

Call the late bands · Module 5 · Logical · 5 min

The bands arrive in 10 minutes. Some bands are late. Priya calls only the bands that are very late. And she must pay each band the correct fee. You let Excel decide.

Practice this in a story

More lessons with IF

Related functions