1. Lighthouse

Level 1 · Three shipping bands with IFS

The request

From Megan Collins, Head of Sales

“We're testing a three-band shipping fee: free from $75, $4.95 from $35, $7.95 under that. The bands are in F1:G4. What would these orders have paid under it?”

Your goal

In D2:D40, use IFS to return each order's shipping fee from the band table: the fee in G2 when the subtotal in column C is at least F2, the fee in G3 when it is at least F3, otherwise the fee in G4. Lock the band cells with $ and fill down.

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

Your sheet

Excel
The sheet for this level
ABCDEFGH
1order_idchannelsubtotalshippingSubtotal fromFee
26001web18.9975.000.00
36002web90.9635.004.95
46003marketplace1634.860.007.95
56004marketplace169.00
66005web630.92
76006web497.98
86007web849.97
96008web73.98
106009web23.98
116010web109.00
126011web1138.95
136012web52.99
146013web343.90
156014app17.99
166015app1186.93
176016app531.84
186017web2608.98
196018web1135.99
206019web246.91
216020web379.00
226021web77.96
236022web19.99
246023web465.97
256024app474.97
266025app98.99
276026app1004.99
286027marketplace43.99
296028marketplace381.99
306029web2851.98
316030web53.07
326032marketplace705.99
336033marketplace29.98
346034app397.99
356035web155.96
366036app99.93
376037app734.99
386038web169.00
396039web92.99
406040web870.96
41
42

Loading the editor…

    ResultPress Check to compare D2:D40

    Mote checks your result

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

    The lesson

    In chapter 1, one IF handled a rule with two outcomes: free shipping or the standard fee. Real rules often have more. Megan’s test has three bands, and the sheet holds them as a small table: F2:G4 lists where each band starts and its fee.

    Nested IF: one IF inside another

    An IF has room for only two outcomes, so the classic way to get three is to put a second IF in the “otherwise” slot of the first:

    =IF(C2>=$F$2,$G$2,IF(C2>=$F$3,$G$3,$G$4))

    Read it from the left: if the subtotal reaches $75, the fee is G2; otherwise ask again, and if it reaches $35 the fee is G3; otherwise G4. It works, and you will see it in many old workbooks. With five or six bands it turns into a wall of brackets where one misplaced ) changes the answer.

    IFS: pairs, read from the left

    IFS writes the same rule as a flat list of pairs, a test followed by the value for that test:

    =IFS(C2>=$F$2,$G$2,C2>=$F$3,$G$3,TRUE,$G$4)
    Pair Means
    C2>=$F$2,$G$2 from $75: fee 0
    C2>=$F$3,$G$3 from $35: fee 4.95
    TRUE,$G$4 anything else: fee 7.95

    IFS checks the tests from left to right and returns the value of the first test that is TRUE. It never looks at the rest. That is what makes the order of the pairs part of the rule.

    Order the tests from the top band down

    Order 6002 (row 3) has a subtotal of 90.96. It passes both >=75 and >=35. Because the $75 test comes first, IFS returns 0 and stops. Swap the first two pairs and the same order matches >=35 first and pays 4.95. So does every order of $75 or more, and the free band never fires.

    When bands are written as “from” amounts, start with the highest and work down. Each later test only sees the orders that failed every test before it.

    The catch-all TRUE

    IFS has no “otherwise” slot. If no test is TRUE, it returns #N/A. Order 6001 (18.99) fails both band tests, so without the last pair D2 shows #N/A. The fix is a final test that is always TRUE: the word TRUE itself. It catches everything left over, so F4 in the band table documents the bottom band without being needed in the formula.

    Checking the result

    Filled down to row 40, the column holds 30 free orders, 4 at 4.95 and 5 at 7.95. Look at the edges: order 6008 at 73.98 (row 9) pays 4.95, and order 6021 at 77.96 (row 22) ships free. If those two look right, the >= tests point the right way. A SUM of the column, 59.55, is what this test would have charged on these 39 orders.

    Common mistakes

    • Testing the lowest band first. C2>=$F$3 before C2>=$F$2 catches the big orders too early, and they pay 4.95.
    • No catch-all. Small orders show #N/A instead of the standard fee.
    • > instead of >=. An order of exactly $35.00 or $75.00 lands in the wrong band.
    • Unlocked band cells. F2 filled down becomes F3, F4, and the bands drift row by row. Lock every cell of the band table with $.

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