Practical DAX Examples Using a Curated Semantic Model | Power BI Tutorial
Artificial intelligence continues to reshape the way we work with data, reporting, and analytics. In a recent video from Pragmatic Works, Mitchell Pearson explored one of the most exciting AI integrations in Microsoft Fabric: using Copilot to write DAX (Data Analysis Expressions). The session highlighted how Copilot can significantly accelerate development within Power BI, but also raised important considerations around accuracy and validation.
Getting Started with Copilot in Power BI
Mitchell begins by showing how Copilot is integrated directly into the DAX Query View in Power BI. By pressing Ctrl + I, users can prompt Copilot to generate DAX queries and measures within their workspace.
- To use Copilot, a Fabric capacity is required. Even an affordable F2 SKU is sufficient.
- Copilot does not work with Fabric free trials.
- Because Copilot is integrated into the model, it understands tables, relationships, and column names, unlike disconnected AI tools.
First Test: Year-to-Date Sales Measure
Mitchell first asks Copilot to create a Year-to-Date (YTD) Sales measure. Copilot generates flawless code using TOTALYTD, automatically referencing the correct sales column and date table. He highlights three key benefits:
- Accuracy: The generated DAX was correct and production-ready.
- Explanations: Users can ask Copilot to explain functions (e.g., TOTALYTD) in simple terms.
- Integration: Queries can be added directly to the data model for use in reports.
Advanced Test: Fiscal Year Ending June 30
The next scenario tested whether Copilot could handle fiscal years ending on June 30 instead of December 31. Copilot not only created the measure correctly but also populated the optional parameter in TOTALYTD to reflect the non-standard year-end. Mitchell notes this is especially useful for new DAX users who may not know about optional parameters.
Complex Example: Top 5 and Bottom 10 Products
Moving into more advanced territory, Mitchell challenged Copilot to create a measure returning total sales for the top five products and bottom ten products. Copilot produced sophisticated DAX involving:
- Variables for product sales calculations
TOPNto retrieve the top 5 and bottom 10 products- Combining results into a single virtual table
SUMXto iterate and calculate the total sales across the combined products
Mitchell expressed surprise at how well-structured the code was. He particularly appreciated Copilot’s flexibility: different runs often produced slightly different but equally correct approaches to solving the same problem.
Asking Copilot for Explanations
A standout feature was the ability to ask Copilot to explain functions like SUMX. It broke down the calculation step-by-step, making it easier for less experienced users to understand advanced DAX logic. This educational aspect adds significant value for learners.
The Big Caution: Validation and Accuracy
While Copilot is powerful, Mitchell emphasized a critical caution: validation is essential. He shared that during his virtual mentoring sessions, many customers arrive with AI-generated DAX that looks correct but produces the wrong results. This can be dangerous because:
- Incorrect calculations may go unnoticed in complex reports.
- Executives and decision-makers might rely on inaccurate data.
- Validating scalar values with multiple filters is often difficult.
The bottom line: Copilot can accelerate development but must not replace a developer’s responsibility to test, validate, and confirm correctness.
Final Thoughts from Mitchell Pearson
Mitchell concludes by sharing his excitement about Copilot’s potential. It can dramatically speed up DAX development, assist with learning, and even write complex queries that would take significant time manually. However, the technology must be paired with human expertise and validation to ensure accuracy.
He invites viewers to share their experiences with Copilot—whether positive success stories or errors that slipped through. Pragmatic Works continues to support professionals through training and Virtual Mentoring programs that help users troubleshoot complex DAX and Power BI scenarios.
Key Takeaways
- Copilot integrates directly with Power BI’s DAX Query View.
- It can generate both simple and complex DAX measures accurately.
- Explanations for functions enhance learning and understanding.
- Validation is critical—never assume AI-generated code is flawless.
- Copilot is a powerful assistant, not a replacement for expertise.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on DAX and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.
Sign-up now and get instant access
ABOUT THE AUTHOR
Mitchell Pearson has been with Pragmatic Works for 10 years as a Data Platform Consultant and the Training Manager. Mitchell has authored books on SQL Server, Power BI and the Power Platform. Data Platform experience includes designing and implementing enterprise level Business Intelligence solutions with the Microsoft SQL Server stack (T-SQL, SSIS, SSAS, SSRS), the Power Platform and Microsoft Azure.
Free Community Plan
On-demand learning
Most Recent
private training

Leave a comment