The request

From Megan Collins, Head of Sales
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:D40with the right valuesnot done yet - With formulas, not typed numbersnot done yet
- Use
IFSnot done yet
Your sheet
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | order_id | channel | subtotal | shipping | Subtotal from | Fee | ||
| 2 | 6001 | web | 18.99 | 75.00 | 0.00 | |||
| 3 | 6002 | web | 90.96 | 35.00 | 4.95 | |||
| 4 | 6003 | marketplace | 1634.86 | 0.00 | 7.95 | |||
| 5 | 6004 | marketplace | 169.00 | |||||
| 6 | 6005 | web | 630.92 | |||||
| 7 | 6006 | web | 497.98 | |||||
| 8 | 6007 | web | 849.97 | |||||
| 9 | 6008 | web | 73.98 | |||||
| 10 | 6009 | web | 23.98 | |||||
| 11 | 6010 | web | 109.00 | |||||
| 12 | 6011 | web | 1138.95 | |||||
| 13 | 6012 | web | 52.99 | |||||
| 14 | 6013 | web | 343.90 | |||||
| 15 | 6014 | app | 17.99 | |||||
| 16 | 6015 | app | 1186.93 | |||||
| 17 | 6016 | app | 531.84 | |||||
| 18 | 6017 | web | 2608.98 | |||||
| 19 | 6018 | web | 1135.99 | |||||
| 20 | 6019 | web | 246.91 | |||||
| 21 | 6020 | web | 379.00 | |||||
| 22 | 6021 | web | 77.96 | |||||
| 23 | 6022 | web | 19.99 | |||||
| 24 | 6023 | web | 465.97 | |||||
| 25 | 6024 | app | 474.97 | |||||
| 26 | 6025 | app | 98.99 | |||||
| 27 | 6026 | app | 1004.99 | |||||
| 28 | 6027 | marketplace | 43.99 | |||||
| 29 | 6028 | marketplace | 381.99 | |||||
| 30 | 6029 | web | 2851.98 | |||||
| 31 | 6030 | web | 53.07 | |||||
| 32 | 6032 | marketplace | 705.99 | |||||
| 33 | 6033 | marketplace | 29.98 | |||||
| 34 | 6034 | app | 397.99 | |||||
| 35 | 6035 | web | 155.96 | |||||
| 36 | 6036 | app | 99.93 | |||||
| 37 | 6037 | app | 734.99 | |||||
| 38 | 6038 | web | 169.00 | |||||
| 39 | 6039 | web | 92.99 | |||||
| 40 | 6040 | web | 870.96 | |||||
| 41 | ||||||||
| 42 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each right cell becomes a firefly in your lantern.
What Megan gets, and why
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$3beforeC2>=$F$2catches the big orders too early, and they pay 4.95. - No catch-all. Small orders show
#N/Ainstead of the standard fee. >instead of>=. An order of exactly $35.00 or $75.00 lands in the wrong band.- Unlocked band cells.
F2filled down becomesF3,F4, and the bands drift row by row. Lock every cell of the band table with$.
Lantern lit!
Practised: ifsnested ifcomparison operators
- Solved
- No hints
- First run
