Library › Coding AI › Office and admin

Summarize approved spend by team with one QUERY formula

Practice: Asking for a format you can use. About 5 minutes.

About this exercise

Write one Google Sheets QUERY formula for Summary!A1 that reads Requests!A1:E (row 1 is headers) and returns each team in column B with the total of column C for Approved rows only (column D), biggest total first. The total column must be labeled Total, and the formula must say there is 1 header row. One formula in one code block, then under 25 words outside the code.

Common mistakes when you ask AI for this

  • Not naming the function. The AI builds a pivot table walkthrough or a pile of SUMIFS instead of one formula. Try: Add: "One QUERY formula for Summary!A1."
  • Leaving the output shape open. The AI keeps the ugly default header sum Cost and its own sort order. Try: Add: "Biggest first, label the total column Total."
  • Forgetting the header row. QUERY guesses how many header rows there are and sometimes guesses wrong. Try: Add: "1 header row, as the last argument."
  • 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

  • Names QUERY
  • Sets the sort and label
  • Mentions the header row
  • Filters to approved
  • Asks for one answer only

Practice this now ↑

Related exercises