{"id":"data2-formula-vendor-terms-lookup-trim","audience":"finance","category":"spreadsheets","track":"data","technique":"constraints","level":"beginner","title":"Write a lookup formula for vendor payment terms","free":false,"task":"Accounts payable needs payment terms next to each invoice. Ask for one Excel formula for C2 in a single code block, with at most 25 words outside it. It should look up the vendor ID from the Vendors tab, ignore stray spaces in the invoice's vendor ID, and show Not found when there is no match. Your team uses Excel 365.","materialLabel":"Your two tabs (attached to your prompt automatically)","material":"Workbook: AP (Excel 365) - Cobalt Analytics\n\nTab \"Invoices\":\nA Vendor ID | B Amount | C Payment terms\nV-100 | 1,200 |\nV-205  | 640 |  (note: typed with a trailing space)\nV-310 | 90 |\nV-999 | 2,500 |\n\nTab \"Vendors\":\nA Vendor ID | B Vendor name | C Payment terms\nV-100 | Alder Tools | Net 30\nV-205 | Birch Paper | Net 45\nV-310 | Cedar Freight | Net 15\n\nNotes:\n- About 3,000 invoice rows; Vendors has about 400 rows.\n- Vendor IDs on the Invoices tab sometimes have stray spaces; the IDs on Vendors are clean.\n- V-999 isn't in Vendors yet.\n- The lookup must match the ID exactly, not approximately.\n- Return the value in Vendors column C.","rules":[{"type":"codeBlocks","count":1},{"type":"maxProseWords","max":25}],"mistakes":[{"title":"Ignoring stray spaces","why":"The AI looks up A2 directly, so 'V-205 ' misses.","fix":"Add: \"Look up TRIM(A2).\"","checks":["r0"]},{"title":"Showing #N/A","why":"The AI leaves the error for missing vendors.","fix":"Add: \"If there is no match, show Not found.\"","checks":["r1"]},{"title":"Approximate match","why":"VLOOKUP without FALSE returns wrong rows.","fix":"Add: \"Exact match only.\"","checks":["r2"]},{"title":"Leaving the format to chance","why":"The AI picks its own length and layout unless told the exact shape.","fix":"Add: \"Put the code in exactly 1 code block. Keep the writing outside the code under 15 words.\"","checks":["codeBlocks","maxProseWords"]}],"promptHints":[{"label":"Mentions TRIM","patterns":["trim"]},{"label":"Asks for exact match","patterns":["exact","false"]},{"label":"Handles missing","patterns":["not found","iferror"]},{"label":"Names the ranges","patterns":["vendors!a:a","vendors!c:c"]},{"label":"Limits the output","patterns":["one formula","single code block","one short sentence"]}],"hint":"Real lookups fail on stray spaces and missing keys. Name both and the match type.","mission":"Look up payment terms in Excel.","musts":["One formula","TRIM the key","Not found text"],"rubricLabels":["The formula looks up TRIM(A2) in Vendors column A and returns Vendors column C (for example XLOOKUP(TRIM(A2),Vendors!A:A,Vendors!C:C,...) or an exact-match INDEX/MATCH or VLOOKUP with FALSE)","The formula returns the text \"Not found\" when there is no match (the not-found argument of XLOOKUP, or IFERROR)","The match is exact (XLOOKUP default exact match, MATCH 0, or FALSE in VLOOKUP) and the reply has one formula in one code block"]}