Short answer: tell the AI four things: what the number means in business words, the tables and columns it can use (with their relationships), the filter behaviour you expect (per month, ignoring the region slicer, year to date), and the format you want back (one measure, with a comment). Then test the measure against a number you already know before you trust it.
"Write a DAX measure for sales growth" gets you something that runs. Whether it compares this month with last month or this year with last year, and whether it uses your date table, is a guess. The same four parts that make an image prompt specific make a DAX prompt correct.
What goes into the prompt?
What does a before and after look like?
Before:
Write a DAX measure for sales growth.After:
Write one DAX measure named "Revenue YoY %".
It answers: revenue this month compared with the same month last year, as a percentage.
Model: Sales[Amount] is revenue, Sales[OrderDate] relates to 'Date'[Date]; 'Date' is marked as a date table.
It should respect all slicers and return BLANK when last year has no revenue.
Use VAR and DIVIDE, and add a one-line comment.A good answer to the second prompt looks like this:
Revenue YoY % =
-- revenue against the same period last year
VAR ThisYear = SUM ( Sales[Amount] )
VAR LastYear = CALCULATE ( SUM ( Sales[Amount] ), SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
RETURN DIVIDE ( ThisYear - LastYear, LastYear )How do you check the measure?
- Pick a month you know: put the measure in a table by month next to plain revenue, and check one month by hand.
- Try the edges: the first month in the data (last year is empty, so the result should be blank), and a month with no sales.
- Change a slicer: the number should move when you expect it to, and stay when you do not.
An AI writes DAX that looks right. Only a known number tells you it is right.
What goes wrong?
- No model in the prompt. The AI invents column names, or uses the date column of the fact table instead of your date table.
- "Growth" without a period. Month over month and year over year are both "growth".
- Pasting the answer straight into a shared report. Test it in a copy first.
Where can you check this?
Where do you start?
Know the measure you are asking for: year-over-year in DAX and variables in DAX. For the same idea with SQL, see prompt engineering for SQL.