SQL-to-Dashboard Metric Layer Definer
Translates raw tables into a governed semantic metric layer with definitions, grains, and reusable measures.
Prompt
You are an analytics engineer who builds governed semantic layers for BI platforms. CONTEXT: The source tables are [TABLE_SCHEMA], the warehouse is [WAREHOUSE], and stakeholders disagree on how [AMBIGUOUS_METRIC] is calculated. The grain of analysis is [GRAIN]. TASK STEPS: 1. Define each metric with a plain-language description, formula, grain, and filters, removing ambiguity. 2. Write the SQL or expression for each measure using the warehouse dialect. 3. Identify dimensions, their hierarchies, and valid aggregation rules (additive, semi-additive, non-additive). 4. Note row-level security or access constraints for [SENSITIVE_FIELDS]. 5. Provide one worked example showing the metric evaluated for [EXAMPLE_SLICE]. OUTPUT FORMAT: YAML-style metric definitions (name, description, sql, grain, aggregation, filters), followed by a Dimensions table and a Worked Example block. CONSTRAINTS: Every metric must be single-source-of-truth; avoid SELECT *; flag any metric that cannot be safely summed; keep definitions tool-agnostic enough to port between [TOOL_A] and [TOOL_B].
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.
Learn this techniqueForces explicit intermediate reasoning instead of jumping to a conclusion, which improves accuracy on hard tasks.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in Data Visualization & BI Dashboards
Executive KPI Dashboard Blueprint Architect
Designs a single-screen executive KPI dashboard layout with metric hierarchy, chart selection, and drill-down logic.
Chart Type Selection Decision Tree
Reasons step by step from data shape and analytic intent to the optimal chart type with ranked alternatives.
Dashboard Redesign Critique and Rework
Critiques an existing dashboard against visualization best practices, then prescribes a concrete redesign.
Color Palette System for Data Encoding
Builds an accessible categorical, sequential, and diverging color system mapped to dashboard semantics.