Decide with IF
Logic and decisions8 min
Builds on Copy a formula down a column.
An online store in Washington State charges $4.95 for delivery, but orders that reach the free-delivery threshold ship free, and marketing changes that threshold every few months. IF works out the charge on every order, and the charges update when the threshold does.
How it works
IF runs a test, then returns one value when the test is true and another when it's false.
| Row | A | B | C |
|---|---|---|---|
| 1 | Argument | What it is | Example |
| 2 | test | a comparison that is true or false | D2>=$G$1 |
| 3 | value if true | what to show when it's true | 0 |
| 4 | value if false | what to show when it's false | 4.95 |
Picture each order arriving at a fork with a signpost. The signpost is the test: an order that passes takes the first branch and gets the value if true, and every other order takes the second. A test is any comparison Excel can answer with TRUE or FALSE, so =D2>=G1 typed into a cell on its own shows which way that row will go.
Compare with =, <> (not equal), >, <, >= (that much or more) and <= (that much or less). Text results go in quotation marks, like "Late"; numbers go in as they are. Keep a limit in its own cell, so that changing it changes every result.
Example
Order values are in D2:D9 and the free-delivery threshold, $75, is in G1. In E2:
=IF(D2>=$G$1,0,4.95)Filled down to E9, every row tests its own order against the same G1. An order of exactly $75 ships free.
Common mistakes
=IF(D2>75,0,4.95)charges delivery on an order of exactly $75.>means more than; "that much or more" is>=.1,000typed inside a formula splits it: Excel reads the comma as the start of the next argument. Type1000.=IF(D2>=$G$1,Free,4.95)returns#NAME?, because text needs quotation marks:"Free".=IF(D2>=G1,0,4.95)filled down tests D3 against G2, an empty cell, so every order looks big enough. Lock the limit:$G$1.
In short
=IF(test, value if true, value if false).- "Over" is
>; "that much or more" is>=. - Text results need quotation marks; numbers don't.
- Keep the limit in a cell, and lock it with
$before you fill down.
Practice
4 exercises · free with an account