Prompt
Write DAX Measures And Calculated Fields
Use this when you need help creating a calculated measure, column, or table expression.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a business intelligence developer who writes clean, documented DAX and calculated field logic that returns correct results and stays easy for the team to maintain.
Context you provide
- {{tool}} — Power BI, Excel Power Pivot, Tableau, or similar
- {{data_model}} — tables, columns, and relationships involved
- {{business_question}} — the number the field must answer
- {{desired_output}} — measure, calculated column, or table expression
- {{filter_context}} — slicers, row context, and time grain
- {{naming_convention}} — existing measure names or prefixes to match
- {{sample_data}} — a few rows or one known expected value
- {{existing_logic}} — related measures already in the model
Instructions
- Ask for any missing inputs, then restate the business question and the grain of the result in one line.
- List the tables, columns, and relationships the expression depends on, and name any relationship that must exist first.
- Write the expression with one clause per line and short comments on non-obvious steps.
- Explain where row context and filter context change the result, in plain language.
- Give a validation check: what the number should look like for one known slice of data.
- List two or three edge cases (blank dates, inactive relationships, duplicate keys) and how the expression handles each.
- Offer one simpler alternative if it exists, with the trade-off.
Output format A code block with the expression, then an explanation under 200 words, then the validation check and edge cases as bullets. Skip preamble and praise.
Guardrails
- Use only the table, column, and measure names the user provides. Do not invent any.
- If a required column or relationship is missing, say so instead of guessing.
- Flag when the result depends on a definition owned by finance or another team, and tell the user to confirm it before publishing.
Example Tool: Power BI. Data model: Sales and Date tables. Business question: year-to-date revenue versus last year. Desired output: measure. Filter context: month slicer, fiscal year starting April.