Sub topic 11
Getting help with metrics, spreadsheets, and SQL
This chapter assumes you know core product metrics (active users, conversion, retention), can use a spreadsheet with formulas and pivot tables, and have used a chat-based AI assistant before. You do not need to write SQL fluently. You do need to read a short query and judge whether it matches your question.
What AI is good for in data work
An AI assistant can speed up four kinds of data work for a PM:
- Explaining. It can describe what a formula, a query, or a metric definition does in plain language.
- Drafting. It can write a first version of a spreadsheet formula, a pivot table plan, or a SQL query.
- Debugging. It can read an error message and the query that caused it, then suggest a fix.
- Interpreting. It can suggest reasons a number might have moved, which you then test against real data.
It does not know your data. It sees only the text you give it. It does not know your table names, your column meanings, or what your company counts as an "active user". Unless you supply those details, it will guess, and the guess will read as confident.
Ground the request in your schema and definitions
The most useful thing you can add to a data prompt is context. Give the model three things:
- The schema. Table names, column names, and types. Paste only structure, not rows of real data.
- The metric definition. For example: "An active user is a user with at least one
project_createdortask_completedevent in the period. Internal test accounts haveis_internal = trueand are excluded." - The SQL dialect. PostgreSQL, BigQuery, Snowflake, and MySQL differ in date functions, quoting, and syntax.
A grounded prompt looks like this:
Role: You are a data analyst helping a product manager.
Context: PostgreSQL. Table events(event_id, user_id, event_name, event_time timestamp, is_internal boolean).
An active user in a week has at least one event named 'project_created' or 'task_completed'. Exclude rows where is_internal is true.
Task: Write a query for weekly active users from 2026-01-01 onward.
Format: One query, then a short list of assumptions you made.
Constraints: Do not invent columns. If a needed column is missing, say so instead of guessing.The final two lines matter. Asking for assumptions makes hidden guesses visible, and the "do not invent columns" constraint reduces made-up fields.
Reading a query you did not write
Here is the kind of query an assistant might return for a weekly active users request:
-- Weekly active users: distinct users with at least one event per week.
SELECT
DATE_TRUNC('week', event_time) AS week_start,
COUNT(DISTINCT user_id) AS weekly_active_users
FROM events
WHERE event_time >= DATE '2026-01-01'
GROUP BY DATE_TRUNC('week', event_time)
ORDER BY week_start;Read it clause by clause and compare it to your definition:
| Clause | What it does | What to check |
|---|---|---|
| `DATE_TRUNC('week', event_time)` | Rounds each timestamp down to the start of its week | Does your company start weeks on Monday or Sunday? PostgreSQL uses Monday. Other systems differ. |
| `COUNT(DISTINCT user_id)` | Counts each user once per week | Correct for "users", wrong if you wanted event counts. |
| `WHERE event_time >= DATE '2026-01-01'` | Limits the date range | The first week may be partial if January 1 is not a week start. |
| No filter on `event_name` | Counts any event | This does not match the definition above. |
| No filter on `is_internal` | Includes test accounts | This inflates the number. |
This query is valid, but it counts any event from any user, including internal accounts. Under the definition given earlier, it overstates activity. Nothing in the output warns you. This is the typical failure: correct syntax, wrong meaning.
A corrected version adds the two filters:
SELECT
DATE_TRUNC('week', event_time) AS week_start,
COUNT(DISTINCT user_id) AS weekly_active_users
FROM events
WHERE event_time >= DATE '2026-01-01'
AND event_name IN ('project_created', 'task_completed')
AND is_internal = FALSE
GROUP BY DATE_TRUNC('week', event_time)
ORDER BY week_start;Common SQL failure modes
Watch for these when you review AI-written queries:
- Wrong join type. An
INNER JOINsilently drops users with no matching row. ALEFT JOINkeeps them. Which one is right depends on your question. - Duplicated rows after a join. Joining to a table with several rows per user multiplies counts.
COUNT(*)then overstates.COUNT(DISTINCT user_id)is often the fix. - Time zones.
event_timemay be stored in UTC while your report is in local time. Day and week boundaries shift. - Null handling. Comparisons with
NULLdo not behave like ordinary values. A filter likeplan <> 'free'drops rows whereplanis null. - Invented tables or columns. The model may reference a column that sounds plausible but does not exist. The database will usually reject it, but a similarly named real column may be used wrongly.
- Dialect mismatch. Functions such as
DATE_TRUNC,DATEADD, andDATE_SUBare not portable across databases.
Spreadsheets and metrics
For spreadsheets, an assistant is useful for formulas you use rarely. Describe the layout and the goal in words:
- Name the columns and what each holds, such as "Column A is signup date, column B is plan, column C is revenue".
- State the tool, because Excel and Google Sheets differ in some functions.
- Ask for the formula and an explanation of each part.
For example, ask for a cohort retention layout, a SUMIFS that totals revenue by plan and month, or a way to clean inconsistent date formats. Then test the formula on three rows whose answers you can compute by hand.
For metrics, you can ask the assistant to propose a definition, list edge cases, or critique a draft. Ask questions such as "What would make this retention metric misleading?" Treat the answers as prompts for your own thinking. The assistant does not know your product's context, and metric definitions are decisions that belong to you and your team.
Interpreting results with care
When you ask "why did sign-ups drop in week 12?", the assistant will produce a list of plausible causes: seasonality, a release, a pricing change, a tracking bug. These are hypotheses, not findings. Use them to build a checklist of things to examine in your own data, such as whether the drop appears across all channels or only one, and whether event volume dropped at the same time as users (which could point to a tracking issue).
A verification routine
Run these steps before a number from an AI-assisted query reaches a slide or a decision:
- Restate the metric definition in one sentence and check each clause of the query against it.
- Run the query on a small slice, such as one day or one account, where you can verify the count independently.
- Compare the total to a number you already trust, such as a dashboard figure. Investigate any gap before explaining it away.
- Ask the assistant to list the assumptions it made, then confirm each one.
- Have an analyst or engineer review any query that feeds a recurring report or a major decision.
A follow-up prompt can support step 4:
List every assumption you made in the query above about columns, filters, time zones, and joins. For each one, say whether it came from my description or from your own guess.This helps you find guesses, but it does not replace your own check. The model can describe its assumptions inaccurately.
Exercise
An assistant gives you a query that counts COUNT(*) of rows after joining users to subscriptions, where some users have several subscription rows. The result is far higher than your known user count. What is the likely cause, and how do you check and fix it?
Show answer
The join produces one output row per matching subscription, so users with several subscriptions are counted several times. Check by comparing COUNT(*) with COUNT(DISTINCT user_id) on the joined result. Fix it by counting distinct users, or by aggregating subscriptions to one row per user before the join. Then compare the corrected total to a figure you already trust.
Exercise
Write the three pieces of context you would add to a prompt asking an assistant for a monthly retention query, and name one thing you would check in the returned query before using it.
Show answer
Add the table schema (names and types), your definition of retention (for example, a user active in the month after signup, excluding internal accounts), and the SQL dialect. Any one check is acceptable, such as confirming the query filters out internal accounts, handles time zones, or uses the right join type. Test it on a small slice where you know the answer.