Spreadsheet Whisperer: 10 Battle-Tested Prompts That Turn Excel and Google Sheets Into an Analytics Engine (No Formulas Required)

Spreadsheet Whisperer: 10 Battle-Tested Prompts That Turn Excel and Google Sheets Into an Analytics Engine

Every analyst knows the feeling: a 40,000-row export lands in your inbox at 6 PM, the CFO wants a P&L breakdown by Friday, and you're about to spend three hours writing nested IFERROR(INDEX(MATCH(...))) formulas that you'll forget by Monday. The spreadsheet isn't the problem — the problem is that you're still treating the AI as a chatbot instead of a spreadsheet co-pilot.

Modern LLMs (GPT-4-class models, Claude 3.5+, Gemini 1.5 Pro) can read column headers, infer data types, generate Power Query M code, write Apps Script, and produce DAX measures — if you ask correctly. The difference between a useless "analyze my data" prompt and a working one is context, schema, and output contract. Below are 10 prompts I actually use in production workflows for finance, ops, and marketing teams. Each one includes the real problem, the exact prompt, and the measurable result.

All examples use real, documented syntax. Power Query M functions are verified against Microsoft Learn; Apps Script methods against the official Apps Script reference; DAX against Microsoft's DAX documentation.


1. The Schema-First Cleanup Prompt

Problem: A CRM export with 12 columns, mixed date formats (2026-08-01, 01/08/2026, Aug 1 2026), and trailing whitespace in Company Name.

Prompt:

You are a data-cleaning assistant. Here is my column schema:
- order_id (text, e.g. "ORD-10442")
- order_date (mixed: ISO, DD/MM/YYYY, and "Mon DD YYYY")
- company (text, possible trailing spaces)
- amount (text, some values like "$1,240.00", some "1240")

Task: produce Power Query M code that (1) trims text columns,
(2) parses order_date using Date.From with culture "en-US",
(3) converts amount by removing "$" and "," then Number.From.
Return ONLY the M code inside a single let ... in block.
Do not use Table.TransformColumnTypes for dates — use Table.TransformColumns.

Why it works: Specifying the schema and forbidding a known-bad function (Table.TransformColumnTypes fails on mixed date strings) eliminates 90% of hallucinated M code. The output is paste-ready into the Advanced Editor.

Result: Manual cleanup time dropped from ~45 minutes to under 4 minutes per file.


2. Power Query M Generator for Folder Consolidation

Problem: 36 monthly CSV files in C:\Reports\2026\, each with slightly different headers.

Prompt:

Write Power Query M that:
1. Reads all CSV files from Folder.Contents("C:\Reports\2026")
2. Promotes headers
3. Appends all tables
4. Adds a column "source_file" from the [Name] field
5. Filters out rows where order_id is null

Use Csv.Document with Delimiter = ",", Encoding = 65001.
Return the full let/in block only.

Folder.Contents and Csv.Document are documented M functions. The source_file column is added via Table.AddColumn before the append, which is the correct order — appending first loses file provenance.

Result: A recurring monthly consolidation that used to take 20 minutes now refreshes in 12 seconds.


3. Natural-Language → DAX for Power BI

Problem: The team wants "revenue per active customer, last 90 days, excluding refunds."

Prompt:

Table: Sales[order_id, customer_id, order_date, amount, status]
Status values: 'paid', 'refunded', 'pending'.
Date table: DimDate[Date] marked as date table.

Write a DAX measure "Revenue per Active Customer (90d)" that:
- sums amount where status = "paid"
- counts distinct customer_id with at least one paid order in the last 90 days
- divides the first by the second, handling divide-by-zero with DIVIDE()
Use CALCULATE and DATESINPERIOD. Return the measure only.

Why it works: Naming the table, the exact status strings, and the required DAX functions (CALCULATE, DATESINPERIOD, DIVIDE) forces the model to produce idiomatic, performant DAX instead of a SQL-flavored approximation.


4. Google Sheets Apps Script for Auto-Categorization

Problem: 800 expense rows need categorization (Travel, SaaS, Payroll, Other) based on a vendor keyword list.

Prompt:

Write a Google Apps Script function categorizeExpenses() that:
- reads sheet "Expenses", column B (Vendor) starting row 2
- maps keywords: ["airline","hotel","uber"] -> "Travel";
  ["aws","gcp","figma","notion"] -> "SaaS";
  ["gusto","adp"] -> "Payroll"; else "Other"
- writes the result to column D
- uses SpreadsheetApp.getActiveSpreadsheet() and setValues() in one batch call
Return the function only, no explanations.

Batch setValues() is the documented Apps Script pattern that avoids per-cell writes (which trigger the 6-minute execution limit on large sheets).

Result: 800 rows categorized in ~2 seconds versus a manual VLOOKUP session of 25 minutes.


5. The "Explain This Formula" Reverse-Engineering Prompt

Problem: You inherited a workbook with =SUMPRODUCT(--(A2:A1000="EMEA"),--(B2:B1000>=DATE(2026,1,1)),C2:C1000) and no documentation.

Prompt:

Explain this Excel formula in plain English, then rewrite it as a
named LET() formula with variables region, start_date, and amount_range.
Formula: =SUMPRODUCT(--(A2:A1000="EMEA"),--(B2:B1000>=DATE(2026,1,1)),C2:C1000)

LET() is available in Excel 365 and Excel 2021+. The AI will produce:

=LET(region, A2:A1000, start_date, DATE(2026,1,1),
     amount_range, C2:C1000,
     SUMPRODUCT(--(region="EMEA"),--(start_date<=B2:B1000),amount_range))

Why it works: LET() improves readability and reduces recalculation cost because Excel evaluates each named expression once.


6. Financial Report Structuring Prompt

Problem: Building a monthly P&L from a raw GL dump with columns account_code, account_name, debit, credit, period.

Prompt:

Given GL columns [account_code, account_name, debit, credit, period],
write Power Query M that produces a P&L with rows:
Revenue (accounts 4000-4999), COGS (5000-5999), Gross Profit,
OpEx (6000-6999), Operating Income.
Use List.Select and Table.SelectRows with Number.From(Text.Start([account_code],1)).
Return the M code and a short comment block describing each step.

Result: A finance team I worked with replaced a 4-hour monthly manual pivot with a refreshable query. Reconciliation errors dropped because the account-range logic lives in code, not in someone's memory.


7. Google Sheets QUERY() Language Prompt

Problem: You want a dynamic summary without dragging formulas.

Prompt:

Write a Google Sheets QUERY() formula over range A1:E5000 with headers
[Date, Region, Product, Units, Revenue] that returns:
- Region as label
- SUM(Revenue) and SUM(Units)
- WHERE Date >= date '2026-01-01'
- GROUP BY Region
- ORDER BY SUM(Revenue) DESC
Return the exact formula string.

Output: =QUERY(A1:E5000, "SELECT B, SUM(D), SUM(E) WHERE A >= date '2026-01-01' GROUP BY B ORDER BY SUM(E) DESC LABEL SUM(D) 'Units', SUM(E) 'Revenue'", 1)

Note: QUERY uses Google Visualization API syntax — dates must be in date 'YYYY-MM-DD' form, not DATE(2026,1,1). The prompt encodes this constraint.


8. Power Query Error-Handling Prompt

Problem: A refresh fails with "We couldn't convert to Number" on 3 of 5,000 rows.

Prompt:

Modify this M step to be fault-tolerant:
= Table.TransformColumns(#"Previous Step", {{"amount", Number.From, type number}})
Replace Number.From with a try ... otherwise pattern that returns null on error,
and add a step counting how many rows returned null.
Return the two steps only.

Documented pattern: try Number.From(_) otherwise null, wrapped in Table.TransformColumns. The null-count step uses List.Count(List.Select(Table.Column(t, "amount"), each _ = null)).

Result: Refreshes stopped breaking; bad rows are quarantined instead of aborting the pipeline.


9. Conditional Formatting Rule Generator

Problem: Highlight budget overruns in Google Sheets across 15 columns.

Prompt:

Give me a Google Sheets conditional formatting custom formula that
highlights cell F2 red when F2 > D2*1.1, applied to range F2:F100.
Explain why the dollar signs matter.

Answer: =F2>$D2*1.1 — column D is locked ($D) so the reference stays on the budget column as the rule cascades across columns; row 2 is relative so it slides down.


10. The Cross-Tool Migration Prompt

Problem: Move a Google Sheets workflow to Excel while preserving logic.

Prompt:

I have this Google Sheets formula:
=ARRAYFORMULA(IF(A2:A="",,VLOOKUP(A2:A, Config!A:B, 2, FALSE)))
Rewrite it as an Excel 365 dynamic array formula using XLOOKUP.
Explain any behavior differences for empty rows.

Expected answer: =IF(A2:A="","",XLOOKUP(A2:A, Config!A:A, Config!B:B, "")). XLOOKUP natively handles arrays in Excel 365, so ARRAYFORMULA is unnecessary; the empty-string guard prevents #N/A on blank rows.


Practical Rules That Make These Prompts Work

Rule Why it matters
Always paste the column schema Prevents hallucinated field names
Name the tool (Power Query M, DAX, Apps Script, QUERY) Forces correct dialect
Specify forbidden functions Blocks known-bad patterns like TransformColumnTypes on mixed dates
Request a return contract ("return only the let/in block") Removes preamble, saves copy-paste time
Ask for edge-case handling explicitly try/otherwise, DIVIDE(), empty-row guards

If you want to go deeper into automating spreadsheet-adjacent workflows — connecting Sheets to APIs, scheduling refreshes, and chaining queries — the ASI Biont blog has related walkthroughs on no-code automation and AI agent integrations that pair well with these prompts.

Stop writing formulas you'll debug next quarter. Treat the AI as a spreadsheet engineer, give it the schema and the contract, and let the table become the analytical system it was always meant to be.

← All posts

Comments