AI is quick at writing SQL and Excel formulas. The trouble is that a query can run fine, return a neat table, and still be wrong by 78%. We know that number because we built a small made-up sales database for this post and ran every query in it. One plausible-looking join, exactly the kind that’s easy to accept from a chatbot without a second look, nearly doubled the revenue figure.
So these AI prompts for data analysis come with two parts: the prompts you can copy into ChatGPT, Claude, Gemini or Copilot, and the checks that catch the mistakes before they reach a slide deck.
Quick answer: Good AI prompts for data analysis give the model your table structure, a few sample rows, the exact question and the rules (how to treat blanks, returns, dates). Ask for the formula or query plus a short explanation and a check you can run. Then verify totals yourself, because AI-written SQL can run without errors and still be wrong.
- Paste the schema and 3 to 5 fake or masked rows, never the full customer file.
- Ask the AI to state its assumptions: blanks, duplicates, returns, time zones.
- In our SQLite test, joining orders to order items inflated revenue from $860.74 to $1,530.74.
- Microsoft says to review and verify anything Copilot in Excel creates before relying on it.
How to prompt AI for data analysis
Every prompt below follows the same shape. It’s the difference between “write a revenue query” and a query that matches your data.
- Structure. Column names, types, and what one row means. “One row per order” and “one row per order line” lead to very different SQL.
- Sample rows. Three to five, with names and emails replaced. Include an awkward one, like a blank amount.
- The question. One business question, in plain words, with the time range.
- Rules. How to treat blanks, returns, refunds, test orders, currencies.
- Output. Which tool (Excel 365, Google Sheets, PostgreSQL, SQLite), plus “explain each step and give me one check I can run.”

The last point matters most. The dialect changes the answer: DATE_TRUNC works in PostgreSQL and fails in SQLite. If you’re new to prompt structure in general, our prompt engineering guide for beginners covers role, context and format in more depth.
AI prompts for data analysis in Excel
These work in any chatbot. Paste the headers and a few rows, then the prompt.
1. Profile the sheet before anything else
Here are my column headers and 5 sample rows from an Excel table named Sales:
[paste]
Before any analysis, list what could go wrong with this data:
blanks, text stored as numbers, duplicate IDs, inconsistent dates or labels.
For each one, give me an Excel 365 formula that counts how many rows have the problem.
You want counts, not reassurance. A formula like =COUNTBLANK(Sales[Amount]) tells you something real. “Your data looks clean” doesn’t.
2. Write the formula, then explain it
Excel 365. Table Sales has columns OrderDate, Region, Amount, Returned (TRUE/FALSE).
Write one formula for total Amount in October 2026 for Region "South", excluding returns.
Treat blank Amount as missing, not zero. Explain each argument in one line,
and tell me what result I should expect for the 5 sample rows above.
The “what should I expect” line is your built-in test. Work the sample out by hand once. If the formula disagrees with your hand total, one of you is wrong, and it’s worth five minutes to find out which.
3. Plan a PivotTable
I want to compare monthly revenue by region in a PivotTable.
Tell me exactly what goes in Rows, Columns, Values and Filters,
how to group OrderDate by month, and which value setting to use (Sum, Count, Average).
Point out anything in my data that would make the pivot misleading.
4. Pick a chart that answers the question
My audience is a manager who has 30 seconds. The question is: [question].
Here is the summary table: [paste].
Suggest one chart type, say why, and write a title that states the finding
in plain words. Don't suggest pie charts with more than 4 slices.
5. Explain a formula you inherited
Explain this Excel formula step by step for someone who knows SUM and IF but not LET or FILTER:
[paste formula]
Then list the cases where it returns an error or a wrong number.
Using Copilot in Excel instead of a chatbot
Microsoft’s Copilot in Excel FAQ says Copilot can generate formulas, create charts and PivotTables, give insights and make changes to the workbook directly. It needs an eligible Microsoft 365 or Copilot plan, a modern file format such as .xlsx, and Calculation Options set to Automatic for editing. The same page tells you to review, edit and verify anything Copilot creates.
One change to know about: Microsoft’s Insider blog post on the =COPILOT function now says the function stopped being available from 14 September 2026. Copilot lives in the side pane instead. Older tutorials that build sheets around =COPILOT() won’t work anymore.
The prompts above still apply inside Copilot. It can already see your table, so skip the paste step, but keep the rules and the “explain and check” request.
AI prompts for SQL analysis
For the SQL part we didn’t just write prompts. We built a tiny fake shop in SQLite 3.45.3 with Python 3.12.4: six customers, ten orders and fourteen order lines. One order has a blank amount, one customer has no region, and two orders were returned. The tables look like this:
customers(id, name, region) -- one row per customer
orders(id, customer_id, order_date, amount, returned) -- one row per order
order_items(id, order_id, product, qty) -- one row per product line in an order
Every query and result below came from that run. The script and full output are saved with this post.
6. Data quality check first
Here is my schema: [paste]. Dialect: SQLite.
Write one query that counts total orders, orders with a NULL amount,
customers with a NULL region, and duplicate order IDs.
Don't fix anything yet. Just count.
On our data the counts came back as 10 orders, 1 NULL amount, 1 NULL region and 0 duplicates. Those two NULLs matter later. Run this before every new dataset, not just the messy ones.
7. Monthly totals with your rules
Dialect: SQLite. Using orders(id, customer_id, order_date TEXT 'YYYY-MM-DD', amount, returned 0/1),
give me order count and revenue per month, excluding returned orders.
Round revenue to 2 decimals. Explain how NULL amounts are handled.
The query we ran used strftime('%Y-%m', order_date) and returned September 165.5, October 260.0 and November 205.24. October has three orders but one has no amount, and SUM quietly skips it. That’s correct for “revenue we know about,” but you should decide that, not the query.
8. Ask for grain before joins
Before writing the query, tell me the grain of each table (what one row means)
and whether any join could repeat rows. Then write SQLite SQL for revenue by region.
If a table isn't needed for the answer, don't join it.
This is the prompt that prevents the biggest bug in the next section. Without it, a query that pulls in order_items “for completeness” looks harmless and isn’t.
9. Rank and compare
Dialect: SQLite 3.45. Show the top 3 customers by spend, excluding returns,
using a window function. Show ties with the same rank.
Our run gave Cara 260.0, Ben 145.49 and Ava 120.0, ranked 1 to 3 with RANK() OVER (ORDER BY spend DESC). Window functions need SQLite 3.25 or newer, which is one more reason to tell the AI your version. For more patterns like this, see our SQL tricks for cleaner queries.
10. Review a query you didn’t write
Review this SQL for logic errors, not style: [paste].
Check for: joins that duplicate rows, integer division, NULL handling in SUM/AVG/COUNT,
filters in WHERE that should be in ON, and date boundaries.
For each issue, show a small input where the result goes wrong.
We ran the SQL: three quiet errors
None of these threw an error. All of them returned a clean-looking table.
The join that doubled revenue. A revenue-by-region query that also joins order_items repeats each order once per product line. Order 104 has three lines, so its $200 got counted three times. Total revenue came out at $1,530.74 against a true $860.74, about 78% too high. Worse, the ranking flipped: South looked like the top region at $735.25, while the correct query puts North first at $345.49 and South at $335.25.

The return rate of zero. SUM(returned) / COUNT(*) returned 0 in SQLite, because both sides are integers and SQLite does integer division. Two returns out of ten orders is 20%. Writing 100.0 * SUM(returned) / COUNT(*) gave 20.0.
The average that depends on a blank. AVG(amount) gave 95.64, because it skips the NULL row. Dividing the sum by all ten rows gave 86.07. Neither is wrong in itself. They answer different questions, and the AI won’t know which one your boss means unless you say.
The part most prompt lists skip: the dangerous AI answer isn’t the one with a syntax error. Those fail loudly and you fix them. It’s the query that runs, looks tidy and is off by a lot. That’s why the best prompts here ask for the grain, the assumptions and a check. A known total you can reconcile against (finance’s monthly number, a row count) is worth more than any clever prompt.
What not to paste into a chatbot
Real customer names, emails, phone numbers, salaries and health data don’t belong in a consumer chatbot, and your company may have rules about which AI tools are approved at all. The prompts above only need structure and a handful of masked rows. If you need the AI to look at the full dataset, use the tool your employer approved (often Copilot in Excel under a work account) and check its data policy first.
A practical habit: replace names with “Customer 1, Customer 2” and round amounts before pasting. The formula or query comes back the same.
Which AI is good for data analysis?
We didn’t benchmark chatbots against each other for this post, so we won’t rank them. The honest answer is that the tool matters less than the prompt and the checks. If your data already lives in Excel under a Microsoft 365 work account, Copilot in Excel saves the copy-paste step. If you’re writing SQL against a database, any major chatbot can draft queries, and our list of AI prompts for coding has more prompts for debugging and review.
Our verdict: use AI to draft, explain and review. Don’t use it as the final word on a number someone will make a decision with. Run the data check, ask for the grain, and reconcile one total by hand. That takes ten minutes and would have caught all three errors above.
Next: learn the basics behind these prompts in our beginner’s guide to prompt engineering.
FAQ
How do I use AI for data analysis?
Give it your table structure, a few masked sample rows, one clear question and your rules for blanks and exclusions. Ask for the formula or query, an explanation, and a check. Then verify a total yourself before sharing the result.
Can ChatGPT write SQL queries correctly?
It can draft them, and the drafts get better when you name the dialect and paste the schema. We didn’t measure its accuracy here. What we did show is that a query can run and still be wrong (see the join example above). Treat AI-written SQL like a colleague’s draft and test it on data where you know the answer.
Is the =COPILOT function still available in Excel?
No. Microsoft’s Insider blog says the =COPILOT function stopped being available from 14 September 2026. Use Copilot in Excel through the side pane instead.
Is it safe to upload company data to an AI tool?
Only to tools your company approves, under a work account. For public chatbots, share structure and masked sample rows, not real customer records.