How to generate DAX Function using Chat GPT for Power BI
In this article I will discuss how to work on DAX code using ChatGPT for Power BI, People they are already working on Power Bi will be familiar with DAX functions which are very useful when we work with Power BI for data visualization. This article is very interesting here we will discuss “How to write DAX functions by using ChatGPT for Power BI”.
Usually, it takes a lot of time for mastering in Power BI DAX functions, but by using ChatGPT we will get the DAX functions very quickly and can easily use in our Power BI projects.
Here we have a Sales Data Set, I used the Sample data set which are already available in Power BI for learning purpose. You can easily access this data set from the below path.
1. Implicit Method
For this Open Power BI Desktop, go to the path.
Help > Examples > Samples dataset > then click Load Sample data.
Then select the financials table and click Load button as shown in the figure.
In the right-side Data Pane, you can see the columns in the financials table.
Here the next step is create a visual which is showing the total sales by country.
For this from the visualization tab, we are selecting a Table visual, then drag and drop the Country and Sales Field from the financials table as shown in the figure.
Now you can see the total sales value against each country in a tabular view, this method is implicit method, here we no need to take extra steps, we need only drag and drop the columns which are already available in the dataset.
2. Write Measure Using ChatGPT (Explicit Measure)
Next, we can write a measure to find the Sum of total sales by country by using ChatGPT, for this you make a ChatGPT query as shown below.
For this we write a ChatGPT query as shown below.
"I have uploaded one table in Power BI
Table name is financials which has column names Country, Sales
Create a DAX function which calculates Sales by country."
Here "financials" is the dataset and Country, Sales are the table columns which are the required columns to generate the sales by country report.
Copy and paste this query into the ChatGPT as shown below,
Then press enter button, you can see ChatGPT generate DAX function which calculates total Sales by country. Copy the function.
In the Power BI create a measure by clicking the New Measure button under Home > Calculations menu.
Then paste the function, which was copied from ChatGPT as shown below,
Now a measure will be created with name Sales_by_Country, drag and drop this measure to the Table visual as shown in the figure,
Here you can see one column Sales_by_Country is created, which is a calculated column by using DAX function and is called as explicit measure and you can use this measure in another table or anywhere the project.
Conclusion
From the above example you can see , by using DAX function generated by ChatGPT and normal explicit method , in both methods the result is showing as same. This is one of the simplest examples, you can write different DAX functions by using ChatGPT for different purposes, only one thing you need care is you write the correct ChatGPT query which can understand by ChatGPT easily, then only ChatGPT can write correct DAX functions which matches for your project.
If this article is useful, please try to share to your friends and social media. In the next article we will discuss how to write DAX functions by using Microsoft Copilot.
Published on:
Learn moreRelated posts
Power BI integration with Microsoft 365 Copilot
Starting June 2026, Microsoft 365 Copilot will integrate with Power BI in Frontier tenants, enabling users to ask questions grounded in Power ...
Optimising DAX: How VertiPaq Stores Your Data
VertiPaq stores Power BI data column-by-column rather than row-by-row. That makes aggregations fast and cross-column queries the trickiest par...
Optimising DAX: A Series Introduction
Optimising DAX in Power BI: VertiPaq storage, compression, model design, how queries run through the storage, formula engines, and performance...
Power BI File Formats Explained: PBIX vs PBIT vs PBIP vs PBIR
Power BI files come in multiple formats. If you have been working with Power BI Desktop for a while, you probably know the PBIX format well. B...
Power BI Tenant Migration: Trade-offs, risks, and realities
Author: Winnie Li, Cloud Solution Architect
AI Can Now Build ANY Power BI Chart You Want
The Optimal Shape for Power BI Data
Why Star Schema Matters More Than Ever in the Age of AI It was over a decade ago that Matt first posted on The Optimal Shape for Power BI Data...
New Power Query experience in Power BI Desktop (Preview)
Authored by: Sara Lammini Rodriguez - Product Manager II, and Miguel Escobar - Senior Product Manager






