The request

From Anna Chen, Sales Manager
Your goal
In D2:D38, use IF with AND and OR to return "yes" when the channel in column B is one of the two online channels in G1 and G2 AND the subtotal in column C is at least the amount in G3, otherwise "no".
- Fill
D2:D38with the right valuesnot done yet - With formulas, not typed numbersnot done yet
- Use
IFANDnot done yet
Your sheet
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | order_id | channel | subtotal | thank_you | Online channel | web | ||
| 2 | 9001 | marketplace | 954.98 | Online channel | app | |||
| 3 | 9002 | marketplace | 904.93 | Note from | 500.00 | |||
| 4 | 9003 | web | 1014.26 | |||||
| 5 | 9004 | web | 2796.00 | |||||
| 6 | 9005 | marketplace | 120.99 | |||||
| 7 | 9006 | app | 169.00 | |||||
| 8 | 9008 | app | 209.64 | |||||
| 9 | 9009 | web | 42.97 | |||||
| 10 | 9010 | app | 618.66 | |||||
| 11 | 9011 | app | 267.98 | |||||
| 12 | 9012 | app | 1678.96 | |||||
| 13 | 9013 | web | 1210.96 | |||||
| 14 | 9014 | web | 44.99 | |||||
| 15 | 9015 | app | 2495.94 | |||||
| 16 | 9016 | marketplace | 392.69 | |||||
| 17 | 9017 | web | 1001.93 | |||||
| 18 | 9018 | web | 219.00 | |||||
| 19 | 9019 | web | 1169.84 | |||||
| 20 | 9020 | web | 237.12 | |||||
| 21 | 9021 | app | 47.97 | |||||
| 22 | 9022 | web | 289.00 | |||||
| 23 | 9023 | app | 367.15 | |||||
| 24 | 9025 | app | 347.83 | |||||
| 25 | 9026 | app | 203.96 | |||||
| 26 | 9027 | web | 195.98 | |||||
| 27 | 9028 | web | 139.00 | |||||
| 28 | 9029 | app | 1426.45 | |||||
| 29 | 9030 | marketplace | 218.97 | |||||
| 30 | 9032 | web | 295.95 | |||||
| 31 | 9033 | app | 836.00 | |||||
| 32 | 9034 | web | 3152.93 | |||||
| 33 | 9035 | web | 86.67 | |||||
| 34 | 9036 | app | 384.96 | |||||
| 35 | 9037 | app | 53.97 | |||||
| 36 | 9038 | app | 896.98 | |||||
| 37 | 9039 | web | 916.97 | |||||
| 38 | 9040 | marketplace | 229.00 | |||||
| 39 | ||||||||
| 40 |
Loading the editor…
Reference solution
Mote checks your result
Press Check. Each right cell becomes a firefly in your lantern.
What Anna gets, and why
The lesson
An IF test can only be one condition, like C2>=500. Anna’s rule has three pieces: the channel
is web, or the channel is app, and the order is at least $500. AND and OR combine several
conditions into one TRUE or FALSE that IF can use.
AND and OR
| Function | TRUE when | Example on row 4 (order 9003, web, 1014.26) |
|---|---|---|
AND(a, b, …) |
every condition is TRUE | AND(B4="web",C4>=500) is TRUE |
OR(a, b, …) |
at least one is TRUE | OR(B4="web",B4="app") is TRUE |
Each takes as many conditions as you like, separated by commas. Neither shows a label on its
own; it returns TRUE or FALSE, which is exactly what the first slot of IF expects.
Nesting them in the right order
Write the rule as a sentence first: “(web OR app) AND at least $500”. The brackets in the sentence become the nesting in the formula:
=IF(AND(OR(B2=$G$1,B2=$G$2),C2>=$G$3),"yes","no")
OR answers “is it online?”, and AND combines that answer with the amount. Row 2 is order
9001, a marketplace order of 954.98: the amount passes, the channel doesn’t, so “no”. Row 21 is
order 9021, an app order of 47.97: the channel passes, the amount doesn’t, so “no” again. Only
orders that pass both parts get “yes”.
The channel names and the amount sit in G1:G3, locked with $, for the same reason as the
shipping threshold in chapter 1: when Anna moves the bar to $750, she changes one cell. Text
comparisons ignore case, so B2=$G$1 matches “web”, “Web” and “WEB”.
NOT flips a test
NOT turns TRUE into FALSE and back. Anna’s rule can also be said as “not marketplace”:
=IF(AND(NOT(B2="marketplace"),C2>=$G$3),"yes","no")
On this sheet it gives the same 13 notes, because there are only three channels. The two
versions differ the day a fourth channel appears: the OR version leaves it out until someone
adds it, the NOT version lets it in. Pick the one that says what the rule really means.
B2<>"marketplace" does the same as NOT(B2="marketplace") with less typing.
AND versus multiplying
You will meet this older trick in shared workbooks:
=IF((B2="web")*(C2>=500),"yes","no")
In arithmetic, TRUE counts as 1 and FALSE as 0, so multiplying two tests gives 1 only when both
are TRUE, and IF treats any non-zero number as TRUE. It works, but it reads like maths, not like
a rule. The + version of OR is worse: on row 4, OR(B4=$G$1,B4=$G$2)+(C4>=$G$3) is 2, not
TRUE, and a SUM of such a column counts some orders twice. Use AND and OR, and keep the
multiplying trick for formulas like SUMPRODUCT that need numbers.
Checking the result
Filled down to row 38, 13 orders get “yes”. A quick cross-check: 15 orders in the sheet are $500 or more, and 2 of those are marketplace orders (9001 and 9002), which leaves 13. Two numbers that agree from different directions are a good sign the formula says what the ticket says.
Common mistakes
- One big OR.
OR(B2=$G$1,B2=$G$2,C2>=$G$3)is TRUE for any web or app order of any size and for every big marketplace order: 33 notes instead of 13. - AND where you meant OR.
AND(B2=$G$1,B2=$G$2)asks for a channel that is web and app at the same time. It is never TRUE, so nobody gets a note. >instead of>=. “$500 and up” includes $500.00 exactly.
Lantern lit!
Practised: andornotiflogical functions
- Solved
- No hints
- First run
