Sub topic 6
Asking for Formulas
Assume you can open Gemini in Google Sheets, select a range, and use basic formulas such as SUM and IF. You should also know how your sheet is organized: which row contains headers, which columns contain inputs, and which cells should contain results.
Gemini can suggest a formula, explain an existing formula, or apply a formula to a selected range. Treat its suggestion as a draft. Read it, test it, and then decide whether to use it.
Describe the calculation precisely
A useful formula prompt names four things:
- The result column or cell.
- The source column or range.
- The calculation to perform.
- What should happen when the source is empty or invalid.
Suppose a sheet has these columns:
| Column | Header | Example |
|---|---|---|
| B | Category | Groceries |
| D | Amount | 42.50 |
| F | Amount with tax | 46.75 |
Select cell F2 and ask Gemini:
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.The suggested formula may be:
=IF(D2="", "", D2*1.1)This formula checks whether D2 is empty. If it is empty, IF returns an empty string, which displays as a blank cell. Otherwise, it multiplies the amount by 1.1, adding 10 percent.
A prompt that says only “add tax” leaves important decisions unspecified. Gemini might choose the wrong source column, tax rate, or blank-cell behavior.
Request a whole-column formula
For a repeated calculation, ask whether the formula should fill each row automatically. For example:
Fill column F from F2 downward with one ARRAYFORMULA. Multiply each non-empty value in D2:D by 1.1, and leave rows blank when D is empty. Explain the result.A possible result is:
=ARRAYFORMULA(IF(D2:D="", "", D2:D*1.1))ARRAYFORMULA is a Sheets function that applies one expression to many rows. This avoids copying a separate formula into every cell.
Before applying it, check that the target range below F2 is empty. Existing values can block the formula and produce an error.
Read the formula before applying it
Ask Gemini to explain unfamiliar functions in plain language:
Explain this formula step by step. Identify the input ranges, conditions, and output for a blank row:
=SUMIF(B2:B, "Groceries", D2:D)The formula adds values in D for rows where the matching value in B is Groceries. SUMIF uses a condition range, a condition, and a values range.
Use a small test case to check the explanation:
| Category | Amount |
|---|---|
| Groceries | 20 |
| Travel | 50 |
| Groceries | 15 |
The expected result is 35. If Gemini’s formula returns another value, inspect the ranges and spelling before using it.
Improve a formula with follow-up prompts
If the first result is close but incomplete, refine it instead of starting over:
Revise the formula so it rounds the tax-inclusive amount to two decimal places and returns blank when D is blank.You can also ask for error handling:
Revise the formula so non-numeric values in D return "Check amount" instead of an error. Explain the change.Check how the revised formula behaves for normal values, blank cells, zero, and invalid text. Manual edits remain useful when the formula is simple or when you need exact control.
Exercise
Write a prompt for a formula in column F that returns the value in D plus 10% tax, stays blank when D is blank, and rounds the result to two decimal places.
Show answer
In column F, add a formula that rounds the value from column D plus 10% tax to two decimal places, and leave the cell blank when column D is empty.