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
Variance with DROP LINES in Power BI
Important Update coming to R and Python visuals in Power BI
Update for R/Py visuals in PBI
Reusing formatting for Power BI reports
Paginated reports supports Power BI language in the Power BI service
Paginated reports supports Power BI language in the Power BI service