Library › Coding AI › Small business owners

Write a sales tax formula that skips wholesale orders

Practice: Giving the right context. About 5 minutes.

About this exercise

Write the tax formula for Orders!F2 (filled down). The tax rate lives in cell $J$1, so don't type 8.25% into the formula. Charge tax only when column D is Y and the customer type in column E is Retail, because wholesale buyers have resale certificates; everything else gets 0. Round the tax to cents with ROUND. One formula in one code block, then under 20 words outside the code.

Common mistakes when you ask AI for this

  • Not saying where the rate lives. The AI types 8.25% into the formula, so the next rate change means editing every row. Try: Add: "Use the rate in $J$1."
  • Forgetting the wholesale rule. The AI only checks the Taxable column, so wholesale orders get taxed. Try: Add: "Tax only if D is Y and E is Retail; otherwise 0."
  • Leaving rounding to chance. The AI skips rounding or uses formatting, so totals drift by pennies. Try: Add: "Round the tax to cents with ROUND(...,2)."
  • 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

  • Points at the rate cell
  • Explains the wholesale rule
  • Asks for rounding
  • Asks for one answer only
  • Limits the explanation

Practice this now ↑

Related exercises