1. Lighthouse

Level 2 · Thank-you notes with AND and OR

The request

From Anna Chen, Sales Manager

“I want to send handwritten thank-you notes for big online orders: web or app, $500 and up. Marketplace orders don't count, we can't contact those buyers. Can you mark which of these get a note?”

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:D38 with the right valuesnot done yet
  • With formulas, not typed numbersnot done yet
  • Use IF ANDnot done yet

Your sheet

Excel
The sheet for this level
ABCDEFGH
1order_idchannelsubtotalthank_youOnline channelweb
29001marketplace954.98Online channelapp
39002marketplace904.93Note from500.00
49003web1014.26
59004web2796.00
69005marketplace120.99
79006app169.00
89008app209.64
99009web42.97
109010app618.66
119011app267.98
129012app1678.96
139013web1210.96
149014web44.99
159015app2495.94
169016marketplace392.69
179017web1001.93
189018web219.00
199019web1169.84
209020web237.12
219021app47.97
229022web289.00
239023app367.15
249025app347.83
259026app203.96
269027web195.98
279028web139.00
289029app1426.45
299030marketplace218.97
309032web295.95
319033app836.00
329034web3152.93
339035web86.67
349036app384.96
359037app53.97
369038app896.98
379039web916.97
389040marketplace229.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

    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.

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