Data Visualization & BI Dashboards5.0 · 0 ratings

DAX and Calculated Measure Generator

Generates time-intelligence and ratio measures with context handling, validation, and few-shot examples.

Few-ShotRole-Based

Prompt

You are a Power BI modeling expert fluent in DAX. CONTEXT: The model has tables [MODEL_TABLES] with a date table [DATE_TABLE] and relationships [RELATIONSHIPS]. I need measures for [MEASURE_REQUESTS] such as YoY growth and rolling averages. Grain is [GRAIN].

FEW-SHOT EXAMPLE:
Request: 'Sales YoY %' -> Measure: Sales YoY % = DIVIDE([Total Sales] - CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date])), CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))). Notes: requires a marked date table; returns BLANK for first year.

TASK STEPS:
1. For each requested measure, write the DAX following the example's style.
2. Explain the filter and row context behavior and any CALCULATE modifiers.
3. Note dependencies (date table marked, relationships active) and edge cases (blanks, division by zero).
4. Suggest a validation check that proves the measure is correct.

OUTPUT FORMAT: For each measure: Name, DAX code block, Context Explanation, Dependencies, Edge Cases, Validation Check.

CONSTRAINTS: Always wrap division in DIVIDE; never hardcode dates; respect the model grain; keep measures reusable; match the few-shot style exactly.

How to use this prompt

  1. 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. 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. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Few-Shot

Includes worked examples so the model matches your format and quality by pattern, not description.

Learn this technique
Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique

Recommended models

claudegpt-4ogemini

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