Google Sheets QUERY formula prompt with explanations
Get a working Google Sheets QUERY formula for filtering, grouping and summarising your data, explained clause by clause with fixes for common errors.
- Published
- Works with
- ChatGPT, Claude and Gemini
- Level
- Intermediate
The QUERY function is the most powerful formula in Google Sheets: it can filter, sort, group and pivot data with one line. It is also easy to break, because column letters, quotes around text and date formats all have strict rules. This Google Sheets formula prompt describes your sheet and the result you want, and returns a working QUERY formula with each clause explained and the usual errors fixed in advance.
The prompt
You are a Google Sheets expert who writes and explains QUERY formulas.
My data:
- Sheet/tab name:
- Range: , header row:
- Columns:
- A few sample rows:
What I want:
Where the result goes:
Filter values that change:
Please:
1. Write the QUERY formula. If filters come from cells, build the query string with & and handle text quotes and dates (date 'yyyy-mm-dd' via TEXT()).
2. Explain each clause (SELECT, WHERE, GROUP BY, PIVOT, ORDER BY, LABEL, FORMAT) in one line.
3. Show what the first rows of the output will look like.
4. List common errors for this formula (mixed data types in a column, wrong column letters, missing quotes, #VALUE from dates) and how to fix them.
5. If data is on another tab or file, show the IMPORTRANGE or Col1 notation version.
6. Suggest a simpler alternative (FILTER, SUMIFS or a pivot table) if it would be easier to maintain.
How to use it
- Describe columns exactly as they appear, including the column letters.
- Paste the formula into an empty area with nothing below or beside it, so the results can spill.
- Test with a known total to confirm the formula counts what you expect.
Tips
- QUERY treats each column as a single type; mixed text and numbers cause blank results.
- Wrap the formula in IFERROR only after it works, or you will hide useful error messages.
Frequently asked questions
What does this prompt do?
Get a working Google Sheets QUERY formula for filtering, grouping and summarising your data, explained clause by clause with fixes for common errors.
Which AI tools does it work with?
It is written for ChatGPT, Claude and Gemini. It also works in other AI tools that accept text prompts, with small changes.
What do I need to fill in?
8 blanks: tab name; e.g. a1:f500; yes / no; letter | header | type, e.g. a | date | date; b | region | text; c | revenue | number; paste 3-5 rows; describe the result, e.g. total revenue by region for the last 30 days, sorted highest first, only where status is "paid"; and more. Click each blue blank on the page, type your details and press Copy prompt.
Is this prompt free to use?
Yes. You can copy and use it for personal and commercial work.