1. Lighthouse

Level 4 · Shipping fees with IF

The request

From Rachel Adams, Customer Support Lead

“Customers keep asking why some orders paid shipping. The rule is free shipping from $75, otherwise the standard fee. Can you fill in what each of these orders should have paid, so we can check them?”

Your goal

In D2:D38, use IF to return the shipping fee for each order: 0 when the subtotal in column C is at least the threshold in G1, otherwise the standard fee in G2.

  • Fill D2:D38 with the right valuesnot done yet
  • With formulas, not typed numbersnot done yet
  • Use IFnot done yet

Your sheet

Excel
The sheet for this level
ABCDEFGH
1order_idchannelsubtotalshippingFree shipping from75
22002web719.93Standard fee7.95
32003marketplace302.95
42004web698.00
52005marketplace1061.99
62007app55.96
72008web56.97
82009web151.95
92010web1146.00
102011app1870.90
112012web3712.89
122013web598.00
132014app376.98
142015marketplace35.98
152016marketplace27.99
162017web315.94
172018app171.63
182019web297.96
192020app379.00
202021marketplace361.96
212022app605.96
222023app425.84
232024web77.97
242025app149.98
252026web448.75
262027marketplace304.16
272028marketplace29.99
282029web818.00
292030web265.94
302031web105.98
312033web818.99
322034web501.97
332035marketplace63.73
342036web311.93
352037web554.99
362038app996.00
372039app257.97
382040marketplace349.00
39
40

Loading the editor…

    ResultPress Check to compare D2:D38

    Mote checks your result

    Press Check. Each right cell becomes a firefly in your lantern.

    The lesson

    So far every formula did the same arithmetic on every row. Business rules are different: they depend on the row. “Free shipping from $75” means one result for some orders and another for the rest. That is what IF is for.

    The three parts of IF

    =IF(test, value_if_true, value_if_false)
    • test: a comparison that is either TRUE or FALSE, like C2>=75;
    • value_if_true: what the cell shows when the test is TRUE;
    • value_if_false: what it shows otherwise.

    For the first order (subtotal in C2), the shipping fee is:

    =IF(C2>=75,0,7.95)

    Read it as a sentence: “if the subtotal is at least 75, shipping is 0, otherwise 7.95”.

    Comparison operators

    Operator Means
    = equal to
    <> not equal to
    > / < greater / less than
    >= / <= greater / less than or equal to

    The difference between > and >= is the edge of the rule. “From $75” includes $75 itself, so the test is >=. When you translate a rule into a formula, ask what happens exactly at the threshold; that is where most disputes with customers come from.

    Text comparisons work too, with the text in double quotes: =IF(B2="web","Online","Other"). They ignore upper and lower case, so "Web" matches web.

    Keep the rule in cells

    The sheet already holds the rule’s inputs: the threshold in G1 and the standard fee in G2. Point at them instead of typing 75 and 7.95 into the formula, and lock them with $ as in the last level, because every row reads the same two cells:

    =IF(C2>=$G$1,0,$G$2)

    Filled down to row 38, each row tests its own subtotal (C3, C4…) against the same threshold. When marketing tries “free shipping from $60” next month, Rachel changes G1 and every fee updates.

    Checking the result

    Once the column is filled, scan it. Orders such as 2015 (35.98) and 2028 (29.99) should show 7.95; big orders should show 0. A quick sanity check like this catches a reversed test, where < was typed instead of >= and every fee lands on the wrong orders.

    Common mistakes

    • Reversing the outcomes. =IF(C2>=$G$1,$G$2,0) charges the fee to exactly the orders that should ship free.
    • Quotes around numbers. "0" and "7.95" are text, not numbers. They look right but break any SUM of the column.
    • Unlocked inputs. =IF(C2>=G1,0,G2) is right in D2 and wrong from D3 down, where the test reads G2 and the fee reads the empty G3.

    Pick what may run on this site. You can change this any time from "Cookie settings" at the bottom of every page.