Library › Coding AI › Finance and accounting
Label budget variances as favorable or unfavorable
Practice: Giving the right context. About 5 minutes.
About this exercise
Write one Excel formula for Budget!F2 (filled down) that shows the variance of Actual (D2) against Budget (C2) as text like +4.2% F or -3.0% U. Percent = (D2 - C2) / C2 with a sign and one decimal. Revenue lines (B2 = Revenue) are favorable when actual is at or above budget; Expense lines are favorable when actual is at or below budget. A budget of 0 must show No budget. One formula in one code block, then under 25 words outside the code.
Common mistakes when you ask AI for this
- Not explaining favorable. The AI treats every increase as good, so higher costs show as favorable. Try: Add: "Revenue: at or above budget is F. Expense: at or below budget is F."
- Not showing the label. The AI returns 0.042 or a separate F/U column. Try: Add an example: "text like +4.2% F or -3.0% U."
- Forgetting unbudgeted lines. Dividing by a 0 budget shows #DIV/0! in the board pack. Try: Add: "Budget of 0 shows No budget."
- 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 10 words. Nothing else."
What a strong prompt includes
- Explains favorable by type
- Shows the label
- Handles zero budgets
- Asks for one answer only
- Limits the explanation
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)