DAX with AI
Use AI to write, explain, debug, and optimize DAX calculations faster, without skipping the fundamentals.
DAX with AI
DAX is one of the areas where AI assistance pays off fastest — measures follow recognizable patterns, and a tool that's seen thousands of them can draft, explain, or debug a formula in seconds. It still takes a developer who understands filter context to check the result.
What AI Can Help With
Explaining Existing Measures
Pasting an unfamiliar measure and asking for a plain-language walkthrough is one of the fastest ways to understand a model you didn't build.
Prompt:
"Explain what this DAX measure does, step by step:
Sales YoY % =
DIVIDE(
[Total Sales] - CALCULATE([Total Sales], SAMEPERIODLASTYEAR(DimDate[Date])),
CALCULATE([Total Sales], SAMEPERIODLASTYEAR(DimDate[Date]))
)"A good explanation should call out how CALCULATE replaces the date filter with the same period last year (what SAMEPERIODLASTYEAR shifts), and why DIVIDE is used instead of /.
Drafting New Measures
Describing the business logic in plain language, rather than starting from a blank formula bar, tends to produce a solid first draft.
Prompt:
"Write a DAX measure for a running total of [Total Sales] by DimDate[Date],
that resets at the start of each fiscal year (fiscal year starts in July)."Treat the result as a first draft — verify function choices, especially around time intelligence, against the model's actual date table setup.
Debugging Calculation Errors
Pasting the measure, the error message (or the wrong result), and a short description of what's expected usually gets a faster diagnosis than searching function documentation from scratch.
Prompt:
"This measure shows Infinity on some rows of my table.
What's wrong?
Margin % = [Gross Margin] / [Total Sales]"Dividing by zero with / in DAX doesn't raise an error: it returns Infinity (or NaN for 0 / 0). The fix is DIVIDE(), which returns blank instead. A good AI response should catch that immediately; one that says "/ by zero throws an error" is repeating a common myth, which is itself a useful signal to check its other claims.
Improving Performance
AI can suggest alternative formulations of a slow measure — trading FILTER for a native filter argument, replacing iterators with a set-based function — though the actual impact should be confirmed with Performance Analyzer or DAX Studio, not assumed from the suggestion alone.
Cautions
- AI-generated DAX can look syntactically correct while still misunderstanding row context vs. filter context — test against known values, not just "it ran without an error."
- AI doesn't know the actual model behind a pasted measure. Relationships, cardinality, and other measures it references all affect correctness, and none of that is visible from a snippet alone.
- Time intelligence functions in particular depend on having a proper marked date table — AI suggestions assume one exists even if the current model doesn't have one.
A Reasonable Workflow
Describe the requirement
|
v
Get an AI-drafted measure
|
v
Read it: does the logic actually match the requirement?
|
v
Test against a known value in the report
|
v
Check performance if the measure is used in a heavily-filtered visualNext Steps
Copilot in Power BI
What Microsoft's Copilot does inside Power BI, what it needs (a paid Fabric or Premium capacity, not just a Pro license), and how to use it well. Covers the narrative visual, summarizing a semantic model, building report pages, DAX queries, and preparing a model so Copilot's answers hold up.
Power Query with AI
Use AI to generate, explain, and troubleshoot Power Query M code and transformation logic.