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
| A | B | |
|---|---|---|
| 1 | Order | Total |
| 2 | A101 | 45 |
| 3 | A102 | 120 |
| 4 | A103 | 80 |
| 5 | A104 | 150 |
| Formula | Result | What it does |
|---|---|---|
=IF(B2>=100,"Free delivery","Delivery fee") | Delivery fee | 45 is less than 100, so the test is FALSE. |
=IF(B3>=100,"Free delivery","Delivery fee") | Free delivery | 120 is 100 or more, so the test is TRUE. |
=IF(B4>=100,0,5) | 5 | IF 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.

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 storyMore lessons with IF
- Late fees · Module 5 · IF with math, <>, =