Sub topic 4
Writing prompts that name ranges and outcomes
This chapter covers how to write prompts for the Gemini side panel in Google Sheets. It assumes you can already open the panel, that your data has a header row with one record per row, and that you know basic formulas such as SUM and IF. The chapters on table, formula and chart generation build on the prompt habits introduced here.
Why prompt wording matters in Sheets
Gemini reads your request together with the sheet that is open. It does not know which of your goals matters most, which column you mean by "the total", or whether blank rows should stay blank. If you leave those points out, it fills the gaps with guesses. A guess can be wrong without looking wrong. A formula can run cleanly and still add the wrong column.
A good prompt removes the guesses. It tells Gemini what to produce, where the input lives, what to do with it, and what to do in unusual cases. Naming ranges and outcomes is the single most useful habit for getting usable results.
The four parts of a strong prompt
Most good Sheets prompts contain four parts. You can write them in one sentence.
| Part | What it answers | Example wording |
|---|---|---|
| Output | What should be created? | "a formula", "a column chart", "a table" |
| Location | Where is the input, and where should the result go? | "using column D", "in column F", "data in A1:E50" |
| Operation | What calculation or grouping is needed? | "plus 10% tax", "total Amount by Category" |
| Edge case | What should happen in unusual rows? | "leave the cell blank when column D is empty" |
Here is the formula prompt from the plan, with the four parts visible:
In column F, add a formula that shows the Amount from column D plus 10% tax, and leave the cell blank when column D is empty.- Output: a formula.
- Location: result in column F, input in column D.
- Operation: add 10% tax.
- Edge case: leave the cell blank when column D is empty.
Compare it with a vague version: "Add tax." Gemini would have to decide which column holds the amount, which tax rate to use, where to put the result, and what to do with empty rows.
Name columns the way your sheet does
Gemini works best when your words match what is on the sheet. You can refer to a column in three ways:
- By header name: "the Amount column".
- By letter: "column D".
- By range: "D2:D".
Header names are readable, and they are the right choice when the headers are unique and spelled out. Letters and ranges are exact, which removes doubt when two columns have similar names, such as "Date" and "Due Date". Combining them is often the safest option: "the Amount in column D".
Use the same spelling as the header. If the header says "Paid By", do not write "payer" and expect a match. Gemini may work out what you mean, but you are relying on it to infer, and inference is where mistakes enter.
Open-ended ranges versus fixed ranges
The range style you choose changes what happens when you add data later.
| Style | Example | Behavior |
|---|---|---|
| Fixed | `D2:D50` | Covers exactly rows 2 to 50. New rows below 50 are ignored. |
| Open-ended | `D2:D` | Covers row 2 to the bottom of the sheet. New rows are included. |
| Whole column | `D:D` | Includes the header, which can break numeric calculations. |
For a sheet that keeps growing, say "from row 2 down" or give an open-ended range. For a snapshot, such as a chart for a finished month, a fixed range is fine and makes the result stable. State which one you want, because Gemini does not know whether your data will grow.
State the outcome, not just the task
A task prompt says what to do: "sum the amounts". An outcome prompt says what you want to end up with: "a total per category, one row per category, sorted from largest to smallest". The second form gives Gemini a way to choose between several valid methods, and it gives you something concrete to check later.
Useful outcome details include:
- The shape of the result: one value, a column, or a small summary table.
- The destination: a specific cell, a new column, or a new sheet.
- Ordering and labels: sorted by amount, with a header named "Total".
- Treatment of blanks, text in number columns, and duplicates.
A table prompt shows this well. It names the purpose and lists each header:
Create a table to track monthly expenses with columns Date, Category, Description, Amount, and Paid By.Because the columns are listed in order, you get the layout you need. If you had asked only for "an expense table", Gemini might add a "Notes" column, skip "Paid By", or choose a different order.
Match the prompt to the kind of result
The three result types need slightly different details.
Tables and templates
State the purpose and list the headers. Add the number of starter rows if you want sample data, and say whether you want formatting such as a bold header row. If you want fields with a fixed set of choices, such as a Status column limited to "Open" and "Done", mention that.
Formulas
State the target cell or column, the source columns, the calculation, and the edge case. The edge case matters most. Formulas applied to a column often meet blank rows at the bottom, and without instructions they may show zeros or errors there.
Charts
Give the chart type, the measure, the grouping, the data range, and a title. The chart prompt from the plan covers all five:
Create a column chart of total Amount by Category using the data in A1:E50, with the title "Spending by Category".The range includes row 1 so that Gemini can read the headers and label the axes from them.
What the answer might look like
When you ask for a summary, Gemini may give you a formula and show it before you apply it. Suppose your prompt is: "In a cell, show the total Amount for rows where Category is Groceries." A correct answer is a conditional sum:
=SUMIF(B2:B, "Groceries", D2:D)The first argument is the range to test (Category in column B), the second is the condition, and the third is the range to add (Amount in column D). Because you named the columns, you can check the result in seconds: column B should be Category, and column D should be Amount.
If you want the same calculation to fill an entire column from a single cell, you would ask for that outcome directly: "fill the whole column from one cell, and leave blank rows empty." A matching answer is:
=ARRAYFORMULA(IF(D2:D="", "", D2:D*1.1))If you want totals for every category at once, ask for a grouped summary:
=QUERY(A1:E, "select B, sum(D) where D is not null group by B label sum(D) 'Total'", 1)The final argument, 1, tells QUERY that the first row is a header. Later chapters explain these functions in detail. Here, notice that each formula follows from a prompt that named the outcome.
A prompt-building workflow
The following process produces consistent results.
- Look at your sheet and write down the columns involved, with their letters.
- Decide the output type: table, formula, or chart.
- Write one sentence that includes the output, the location, the operation, and the edge case.
- Read Gemini's answer before applying it. Check that it uses the columns you named.
- Apply it to a small part of the data, then compare it with a manual calculation.
- Adjust with a follow-up prompt if something is off.
Common mistakes
- Vague column references. "The total" could mean the Amount, the tax-inclusive amount, or a sum row. Name the column.
- Ranges that include headers. A range such as
D:Dincludes the header text, which can cause errors or wrong counts in numeric calculations. Start from row 2 for calculations, and start from row 1 only when a function or chart needs headers. - Missing edge cases. If you do not say what to do with empty cells, you may get zeros, errors, or repeated values in blank rows.
- Several tasks in one prompt. A prompt that asks for a table, three formulas and two charts gives a mixed result that is hard to check. Ask for one thing at a time.
- Messy source data. If the Amount column contains text such as "12 USD", even a perfect prompt will not produce a correct sum. Clean data layout comes before prompt design.
- Assuming the result is right. Gemini can misread a column or choose an unexpected function. Always check the output.
Prompt length and level of detail
A longer prompt is not always better. Aim for the shortest prompt that contains all four parts. If your prompt grows past two or three sentences, you are probably asking for more than one thing. Split it into separate prompts and verify each result before moving on.
Add detail where wrong guesses would be costly: money, dates, and anything you will share. Keep it short where any reasonable answer works, such as a quick sample table for practice.
Rewriting a weak prompt
Take a weak prompt: "Make a chart of my spending."
Problems: no chart type, no range, no grouping, no title. Gemini must guess all four.
Improved prompt:
Create a column chart of total Amount by Category using the data in A1:E50, with the title "Spending by Category".Each guess is now an instruction. If the chart still looks wrong, you can tell which instruction to change, for example the chart type or the range, rather than starting over.
Exercise
A sheet has headers in row 1: Date (A), Category (B), Description (C), Amount (D), Paid By (E). You want a formula in column F that shows Amount plus 10% tax and stays empty on rows where Amount is empty. Write a prompt that contains all four parts (output, location, operation, edge case), and name which part each phrase supplies.
Show answer
Example: "In column F, add a formula that shows the Amount from column D plus 10% tax, and leave the cell blank when column D is empty." Output: "a formula". Location: "In column F" (result) and "column D" (input). Operation: "plus 10% tax". Edge case: "leave the cell blank when column D is empty".
Exercise
You asked Gemini for "the total spending" and it returned a formula that sums column D, but you wanted only the Groceries rows. Which part of the prompt was missing, and how would you rewrite it?
Show answer
The operation lacked a condition. Rewrite it as: "In one cell, show the total of the Amount in column D for rows where Category in column B is Groceries." A correct formula is =SUMIF(B2:B, "Groceries", D2:D).
Exercise
Why is the range D2:D usually safer than D:D for a numeric calculation, and when would you choose D2:D50 instead?
Show answer
D:D includes the header cell in row 1, which is text and can cause errors or wrong results. D2:D starts below the header and also picks up rows added later. Choose D2:D50 when you want a fixed snapshot that ignores rows added after row 50.