Writing DAX Measures with AI
DAX is the formula language that makes Power BI calculate. Total revenue, this-year-versus-last-year, average order value, percent of total, they are all DAX measures. DAX is powerful, but its syntax intimidates beginners, and even experienced analysts reach for help on tricky formulas. This is the single best place to let AI do the typing while you stay the decision-maker.
In this lesson you will learn what a measure is, how to describe the calculation you want so AI writes correct DAX, and how to paste it into Power BI and verify it. By the end you will have created several real measures without memorizing a single function.
What You'll Learn
- What a DAX measure is and how it differs from a column
- How to write an AI prompt that produces correct, pasteable DAX
- The handful of measures every dashboard needs
- How to paste, test, and fix DAX with AI's help
Measures vs Columns, the One Thing to Understand
There are two kinds of calculations in Power BI, and mixing them up is a common beginner trap.
- A calculated column computes a value for every row and stores it, like a new column in a spreadsheet. Use it when you need a per-row value, for example, Profit = Revenue - Cost on each order.
- A measure computes a value on the fly based on whatever filters are active, like a total that changes when you click a region. Use it for aggregations: totals, averages, ratios, growth.
Most of what you show on a dashboard, totals and KPIs, should be measures, because they respond to slicers and chart context. When in doubt, ask AI: "For [calculation], should I use a measure or a calculated column in Power BI, and why?" It will guide you correctly almost every time.
The Prompt Recipe for Good DAX
AI writes great DAX when you give it three things: your table and column names, the calculation in plain English, and the context (any Date table or filters). Use this template:
"I'm using Power BI. My relevant tables and columns are:
- Sales: OrderDate, Region, Quantity, Revenue, Cost
- Date: Date, Year, Month
Write a DAX measure (not a column) named 'Total Revenue' that sums Revenue. Then write one named 'Profit Margin %' that is (Revenue - Cost) divided by Revenue, formatted as a percentage. Show the DAX and tell me exactly where to paste it. Keep each explanation to one sentence."
Naming the tables and specifying "measure, not column" prevents the two most common mistakes. Asking for the paste location saves you hunting through menus.
The Core Measures Every Dashboard Needs
Ask AI for these and you will cover most beginner dashboards:
- Total Revenue —
SUMof your revenue column. - Total Quantity / Orders / Count —
SUMorCOUNTROWS. - Average Order Value — Total Revenue divided by number of orders.
- Profit and Profit Margin % — Revenue minus Cost, and that over Revenue.
- Year-over-Year growth — this year versus the same period last year, using the Date table.
- Percent of Total — a region's share of overall revenue.
A single prompt can generate all of them:
"Give me the DAX for these six Power BI measures using my Sales table (Revenue, Cost, OrderID) and Date table: Total Revenue, Total Orders, Average Order Value, Profit, Profit Margin %, and Revenue YoY %. Name each measure clearly and add a one-line comment explaining each."
You will get a ready-to-paste set. This is the moment the course promise, "write DAX without code", becomes real: you described outcomes in English and received working formulas.
Pasting a Measure Into Power BI
- In the Report or Model view, find the Data pane on the right.
- Right-click the table you want the measure in (often your fact table) and choose New measure.
- Delete the placeholder text and paste the DAX from your assistant.
- Press Enter. The measure appears with a small calculator icon.
- Set its Format (currency, percentage) on the Measure tools ribbon, or ask AI which format fits.
Drag the new measure onto a card or chart to see it in action.
When DAX Throws an Error
Errors are normal and easy to fix with AI. Copy the exact error message and the DAX, then paste both:
"I pasted this DAX measure in Power BI and got this error. Explain what's wrong in plain English and give me the corrected measure. Measure: [paste] Error: [paste]"
Common causes AI will spot instantly: a column name that does not match your model, using a column where a measure was expected, or a missing Date table for time functions. Fix, paste, re-test.
Always Verify the Number
AI can write syntactically perfect DAX that computes the wrong thing. Verify with a known value. If you know total revenue should be roughly 1.2 million from your spreadsheet, and the measure shows 1.2 million, trust it. If it shows 12 million or 120,000, something is off, maybe duplicates were not removed, or the measure double-counts. Cross-check one number by hand or in Excel before you rely on the whole dashboard.
A good habit: build a simple table visual listing each measure once, with no slicers, and eyeball the totals against what you expect. Ask AI to help interpret: "My Total Revenue measure shows 12M but my spreadsheet says 1.2M. What are the likely causes in Power BI?"
Practice Exercise
Using your practice dataset, ask your assistant for the six core measures above with your real column names. Paste them in one by one, format each, and drop them onto cards. You now have the building blocks of every dashboard, and you wrote none of the syntax yourself. That is the workflow professionals increasingly use too.
Key Takeaways
- A measure calculates on the fly based on active filters; a calculated column stores a per-row value. Most dashboard KPIs are measures.
- Give AI your table and column names, the calculation in plain English, and specify "measure, not column" for correct DAX.
- Six core measures, Total Revenue, Total Orders, Average Order Value, Profit, Profit Margin %, and Revenue YoY %, cover most beginner dashboards.
- Paste DAX via New measure, set its format, and drop it on a visual. Paste any error back to AI for an instant fix.
- Always verify against a known number; AI can produce perfectly formatted DAX that calculates the wrong thing.

