{"id":"code-work-sb-unique-customers-month","audience":"small-business","category":"coding","track":"coding","technique":"context","title":"Count unique customers in a month with one formula","free":false,"task":"Write one Google Sheets formula for Summary!B2 that counts unique customers who ordered in the month whose first day is in Summary!$B$1. Orders are on the Orders tab: dates in column A, emails in column C from row 2 down. Customers type their email differently each time, so match emails lowercased and trimmed. Show 0, not an error, for a month with no orders. One formula in one code block, then under 25 words outside the code.","materialLabel":"Orders tab preview (attached to your prompt automatically)","material":"ORDERS tab - Copper Kettle Candle Co. (row 1 is headers, about 900 rows this year)\nA Date | B Order # | C Email | D Total\n10/02/2026 | CK-10398 | marisol.vega@mailbox.example | $42.00\n10/05/2026 | CK-10404 | Marisol.Vega@mailbox.example  | $18.00\n10/09/2026 | CK-10410 | theo.b@mailbox.example | $64.50\n10/30/2026 | CK-10421 | aiko.tanaka@post.example | $25.00\n11/01/2026 | CK-10422 | theo.b@mailbox.example | $32.00\n11/03/2026 | CK-10431 | THEO.B@MAILBOX.EXAMPLE | $14.00\n\nSummary tab:\nA1: Month starting | B1: 10/1/2026\nA2: Unique customers | B2: ?\n\nNotes from Bea:\n- Some people check out as guests, so the same person can have several orders.\n- I change B1 each month for the newsletter report.\n- December is always our busiest month.","rules":[{"type":"codeBlocks","count":1},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Not mentioning messy emails","why":"The AI counts Marisol.Vega@ and marisol.vega@ as two customers.","fix":"Add: \"Match emails lowercased and trimmed.\"","checks":["r0"]},{"title":"Not saying where the month is","why":"The AI types October into the formula or uses this month.","fix":"Add: \"The month's first day is in $B$1.\"","checks":["r1"]},{"title":"Forgetting empty months","why":"FILTER errors when nothing matches, and COUNTA of an error shows 1.","fix":"Add: \"Show 0 for a month with no orders.\"","checks":["r2"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the formula, so you're left to pick and test them yourself.","fix":"Add: \"Give one formula only, in one code block, no alternatives.\"","checks":["codeBlocks"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 10 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Handles messy emails","patterns":["lower","trim","capital"]},{"label":"Points at the month cell","patterns":["b1","first day"]},{"label":"Handles empty months","patterns":["\\b0\\b","zero","no orders","iferror"]},{"label":"Asks for one answer only","patterns":["\\b(one|single|1)\\s+(formula|code block|block|version)","only one","no (alternatives|options|other versions)"]},{"label":"Limits the explanation","patterns":["\\d+\\s*words","no (explanation|notes|commentary)","one (short )?(line|sentence)","nothing else"]}],"hint":"Look at Theo's three orders. Tell the AI how to treat those emails, where the month lives, and what an empty month should show.","rubricLabels":["Lowercases and trims the emails (LOWER and TRIM on Orders!C2:C) before taking UNIQUE, so Marisol's two spellings count once","Keeps only orders on or after $B$1 and before EDATE($B$1,1) (or on or before EOMONTH($B$1,0)) using the dates in Orders!A2:A","Returns 0 when the month has no orders (for example IFERROR(...,0) around the count), not an error or 1"]}