Skip to main content

Claude/ChatGPT Prompt to Build a KPI Dashboard SQL Query Set

Generate a complete set of business KPI SQL queries: DAU, weekly revenue with WoW delta, funnel, retention cohorts, and top-N usage.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt casts the AI as a senior analytics engineer and makes it generate a complete set of runnable KPI queries with documented assumptions, not loose fragments. You supply [business_type], [db_engine], your [tables], and the [product_or_feature] to rank in the top-N. It returns daily active users over a configurable range, weekly revenue with a week-over-week delta, a conversion funnel, a retention cohort table by signup week, a top-N usage query, and inline comments stating each KPI's definition, source tables, and grain.

The structure works because it pins definitions in the SQL itself. The hardest part of a metrics layer is rarely the chart — it is agreeing what "active" and "retained" mean. By forcing an inline comment on each query stating the assumed grain and source tables, the prompt makes those definitions explicit and reviewable. [business_type] shapes which activation event the funnel targets, [tables] grounds the queries in your real schema, and [db_engine] governs window-function syntax.

When to use it

  • You are drafting a metrics layer and need every KPI defined before anyone builds a chart.
  • You and your team disagree on what "active" or "retained" should mean in SQL.
  • You want DAU, weekly revenue, a funnel, cohorts, and top-N in one consistent pass.
  • You need each query's grain and source tables documented to prevent later disputes.
  • You want window functions used where they genuinely simplify the logic.
  • You are standing up a dashboard and want the SQL before the visualisation work starts.

Example output

You get one labelled SQL block per KPI: daily active users over a configurable date range, weekly revenue with a WoW delta column, a conversion funnel from first touch to the key activation event, a retention cohort table by signup week, and a top-N of your chosen entity by usage. Each block carries inline comments stating the KPI's definition, source tables, and assumed grain.

Pro tips

  • List your real [tables] accurately — the queries reference them directly, so a wrong table name means rework rather than a paste.
  • Set [business_type] so the funnel's activation event matches your model; a B2B subscription funnel differs from an e-commerce one.
  • Use the inline grain-and-source comments as the contract; they prevent most "the numbers look wrong" arguments later.
  • Pin every metric definition with your team before anyone builds a chart on top of it.
  • Pick [product_or_feature] deliberately so the top-N ranks the entity you actually care about, whether features, products, or pages, and the ranking answers a real question.
  • Treat the configurable date range on the DAU query as a parameter to wire into your dashboard rather than a hardcoded window, so the same SQL serves multiple views.
  • Confirm the [db_engine] matches your warehouse, since window-function syntax and date handling vary between engines and a mismatch produces queries that look right but fail to run.

Frequently Asked Questions

Will the queries run against my actual tables?
They reference the tables you list in `[tables]`, so accuracy there is what makes them runnable. The model assumes a reasonable grain and column set, which you should verify against your real schema before trusting the numbers, since assumptions can drift from reality.
How does it define active and retained?
It states each definition in an inline comment on the query, including the grain and source tables it assumes. That makes the definitions explicit and reviewable, which is the point, but you should still confirm those definitions match how your business actually counts active and retained users.
Can it handle retention cohorts?
Yes, it produces a retention cohort table grouped by signup week. The cohort logic uses window functions where they simplify it, so review the grain comment to confirm the weekly cohort definition matches the time bucketing your team expects.
Does it work for a non-SaaS business?
Set `[business_type]` to your model and it adapts the funnel and activation event accordingly. The DAU, revenue, and top-N queries generalise well, though you should still review the funnel's activation event to make sure it reflects your real conversion path.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Data & SQL Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support