Library › Coding AI › Finance and accounting

Bucket unpaid invoices by days past due

Practice: Setting limits and rules. About 5 minutes.

About this exercise

Write the aging bucket formula for AR!F2 (filled down). Measure from the month-end date you keep in cell $H$1, not today's date: days late = $H$1 minus the due date in D2. Negative amounts in C are credit memos and must show Credit before any date check. Use exactly these labels: 0 or fewer days is Not due, then 1-30, 31-60, 61-90, and 91 or more is 91+ (the pivot table matches on these exact labels). One formula in one code block, at most 3 lines, then under 20 words outside the code.

Common mistakes when you ask AI for this

  • Not giving the as-of date. The AI uses TODAY(), so the report changes every day and won't tie to month-end. Try: Add: "Use the date in $H$1, not TODAY()."
  • Forgetting the credit memos. The AI can't know a negative amount means a credit, so credits land in an aging bucket. Try: Add: "Negative amounts show Credit, checked first."
  • Leaving the labels open. The AI picks its own bucket names and cutoffs, so your pivot table breaks. Try: List them exactly: "Not due, 1-30, 31-60, 61-90, 91+."
  • Getting a menu of options. The AI likes to offer two or three versions of the formula, so you're left to pick and test them yourself. Try: Add: "Give one formula only, in one code block, no alternatives."
  • Getting a tutorial. By default the AI explains every part of the code at length, which you then have to scroll past. Try: Add: "After the code, one line under 12 words. Nothing else."

What a strong prompt includes

  • Uses the as-of date
  • Handles credit memos
  • Spells out the buckets
  • Asks for one answer only
  • Limits the explanation

Practice this now ↑

Related exercises