ChatGPT with Power BI: Two Ways to Skip the DAX Guesswork - PC Webinars blog post

ChatGPT with Power BI: Two Ways to Skip the DAX Guesswork

Every Power BI user hits the same wall eventually. The report looks fine, the data is loaded, and then you need one measure — last year’s sales for the same period, a running total that respects your filters — and you lose forty minutes to a formula that is six lines long and refuses to work.

Using ChatGPT with Power BI fixes a surprising amount of that, but only if you feed it the right things. Left to guess, it will cheerfully invent column names that don’t exist in your model and hand you a measure that returns an error the second you drop it on a visual. Fed properly, it writes the DAX in about ten seconds and explains what every function in it does.

Here are the two prompts I keep coming back to in class. Neither needs a plugin or a paid add-in — just the free chat window and a Power BI file you already have open.

1. Use ChatGPT with Power BI to Write the DAX Measure You’re Stuck On

The mistake almost everyone makes is asking for the formula without describing the model. “Write me a DAX measure for sales last year” gets you a generic answer built on table names you’ve never heard of. The fix is to spend ten seconds typing out your actual schema first.

Open Power BI Desktop, switch to Model view on the left-hand rail, and click the table you’re working with. The column names and data types are right there in the Properties pane. Now write the prompt like this:

I'm writing a DAX measure in Power BI Desktop. My fact table is Sales with columns OrderDate (date), CustomerID (text), and Amount (decimal). I have a separate date table called Calendar, with a one-to-many relationship from Calendar[Date] to Sales[OrderDate]. Write a measure that returns total sales for the same period last year, and explain what each function is doing and why.

What comes back is a CALCULATE wrapped around SUM(Sales[Amount]) with SAMEPERIODLASTYEAR(Calendar[Date]) as the filter — written against your column names, so it pastes straight into a new measure and runs. The explanation underneath is the part that actually pays off: next time you need year-to-date or a rolling three months, you’ll recognize the shape of it.

The gotcha: if the measure returns blank on every row, the problem is almost never the formula. It’s that your Calendar table hasn’t been marked as a date table. Click the table, go to Table tools > Mark as date table, and pick your date column. The time intelligence functions all quietly fail without it, and ChatGPT has no way of knowing you skipped that step unless you mention it.

One more thing: if you paste sample rows to show the data’s shape, strip the real customer names out first. Three made-up rows demonstrate the pattern just as well.

2. Turn a Messy Column Into Power Query M Code in One Prompt

The other place this pays off is upstream, in Power Query, where the real time goes. You know the column — somebody’s export where every cell reads Smith, John - Region 3 (Active) and you need four separate fields out of it.

You can click your way through Split Column four or five times and end up with a query full of steps nobody can read later. Or you can ask for the M code directly:

  • Open the Power Query Editor (Home > Transform data).
  • Click Home > Advanced Editor and copy the let block that’s already there.
  • Paste it into the chat with this: Here is my existing Power Query M code. The column named Rep contains values like "Smith, John - Region 3 (Active)". Add steps that produce four new columns: LastName, FirstName, RegionNumber, and Status. Return the complete let expression so I can paste it back into the Advanced Editor.

Pasting your existing let block is the whole trick. It tells the model exactly what your last step is named, so the new code chains onto it instead of referencing some step called #"Changed Type" that doesn’t exist in your query. That single detail is the difference between code that runs and code that throws a reference error on line one.

The gotcha: M is case-sensitive and unforgiving about it. Text.BetweenDelimiters works; text.betweendelimiters does not. If the Advanced Editor underlines something in red, check the capitalization before you assume the logic is wrong. And glance at the step list afterward — understand what was added, not just that it ran.

Plenty more on the calendar

If you want to watch this done live rather than read about it, I’m running How to Integrate ChatGPT with Power BI: Step-by-Step Guide on Friday, November 13. We build measures from a described model, clean columns in Power Query with generated M code, and — just as importantly — work on spotting the moments when the AI is confidently wrong about your data.

The full current schedule lives on the front page of PCWebinars.com, and new dates go up there as they’re confirmed. Register for this one, or browse the rest and find the session that matches what’s slowing you down this month.

About your trainer

I’m Tom Fragale. I’ve spent more than 30 years as a computer trainer and consultant, and I’ve taught well over 30,000 people how to get more out of the software they’re already paying for — Excel, Access, Power BI, Word, Outlook, and now the AI tools layered on top of all of it: Claude, ChatGPT, and Microsoft Copilot. My background is applied rather than theoretical. Alongside the teaching, I build real databases and reporting systems for clients in Excel, Access, and Power BI, which means the examples I bring to class are problems I ran into last week, not textbook exercises. I also publish free tutorials on YouTube and longer courses online.

You’ll find the full schedule, the recorded courses, and a good deal of free material over at PCWebinars.com.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *