Skip to content

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.

RowABC
1ArgumentWhat it isExample
2testa comparison that is true or falseD2>=$G$1
3value if truewhat to show when it's true0
4value if falsewhat to show when it's false4.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)
Charges nothing when the order in D2 reaches the threshold in G1, and 4.95 when it doesn't.

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,000 typed inside a formula splits it: Excel reads the comma as the start of the next argument. Type 1000.
  • =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

Start practicing
  1. Not started

    1. Over budget or not

    Formula · easy

  2. Not started

    2. Who gets a bonus

    Formula · medium

  3. Not started

    3. Met the target time

    Formula · medium

  4. Not started

    4. Commission for reaching target

    Formula · hard