<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:webfeeds="http://webfeeds.org/rss/1.0">

<channel>
	<title>SQLBI</title>
	<atom:link href="https://www.sqlbi.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sqlbi.com</link>
	<description>Business Intelligence with passion</description>
	<lastBuildDate>Fri, 04 Dec 2026 08:08:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>
            <webfeeds:icon>https://www.sqlbi.com/logo/icon.svg</webfeeds:icon>
            <webfeeds:logo>https://www.sqlbi.com/logo/icon.svg</webfeeds:logo>
            <webfeeds:accentColor>ec5d5d</webfeeds:accentColor>
            <webfeeds:related layout="card" target="browser" />
            <webfeeds:analytics id="UA-7095697-2" engine="GoogleAnalytics" />
        	<item>
		<title>SQLBI in-person courses 2027: pre-order now and save 20%</title>
		<link>https://www.sqlbi.com/blog/marco/2026/12/03/sqlbi-in-person-courses-2027-pre-order-now-and-save-20/</link>
					<comments>https://www.sqlbi.com/blog/marco/2026/12/03/sqlbi-in-person-courses-2027-pre-order-now-and-save-20/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Thu, 03 Dec 2026 10:30:16 +0000</pubDate>
				<guid isPermaLink="false">https://www.sqlbi.com/?post_type=blogpost&#038;p=910062</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/courses-2027-lineup-logo1.png" class="webfeedsFeaturedVisual" /></figure>A few weeks ago, we asked our customers which topics matter most now that AI is quickly changing how we work with data. We included topics with and without AI, and the feedback we received is that we should serve&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/courses-2027-lineup-logo1.png" class="webfeedsFeaturedVisual" /></figure><p>A few weeks ago, we asked our customers which topics matter most now that AI is quickly changing how we work with data. We included topics with and without AI, and the feedback we received is that we should serve different needs: shorter courses where AI agents handle the execution, and classic in-depth courses, including Optimizing DAX.</p>
<p>Thus, <strong>in 2027 we are changing our offer</strong> and bringing four courses to the classroom, initially in the United States and in Europe. In addition to the new Mastering DAX we updated in September 2026, we will bring the second edition of Optimizing DAX to the classroom for the first time. Both courses are delivered in 3 days.</p>
<p>We will also add <strong>two new courses</strong>: Data Modeling with AI for Power BI and DAX with AI, both delivered in 2 days. These new courses explain how to check, understand, and fix models and formulas created by AI tools.</p>
<p><a href="https://www.sqlbi.com/wp-content/uploads/courses-2027-lineup-logo.svg"><img fetchpriority="high" decoding="async" class="alignnone wp-image-910140" src="https://www.sqlbi.com/wp-content/uploads/courses-2027-lineup-logo.svg" alt="" style="border: none !important" width="806" height="383" /></a></p>
<p>Now, the hard part is allocating our offer to meet demand; we must decide which cities, which months, and how many editions of each course. This is why we are opening pre-orders before we publish the schedule: your registration tells us where you are and which course you want. We will use that information to plan editions where and when people need them. We will publish the schedule for the first half of 2027 by January 31.</p>
<p>To thank you for registering this early, we offer a <strong>20% discount on every seat purchased by December 31, 2026</strong>. It is the lowest price we plan to offer for these courses in 2027. <strong>Group discounts apply on top</strong> of it, so a team of three saves 36%, and a team of four or more saves 40%.</p>
<p>If you can use what is left of the 2026 training budget that will be delivered early next year, this is your chance. Your pre-order will help us to better allocate locations and dates for our classes.</p>
<p>However, we know it can feel strange to buy a seat before you know the date. For this reason, you can request a full refund for any unused seat until December 31, 2027: if you don't find a date or location that works well, you will get your money back.</p>
<p>You will find the course descriptions, a short video, and all the conditions on the <a href="https://www.sqlbi.com/training/preorder-classroom-courses/"><strong>pre-order page</strong></a>. We look forward to seeing you in class next year!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/blog/marco/2026/12/03/sqlbi-in-person-courses-2027-pre-order-now-and-save-20/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Handling blank dates in DAX</title>
		<link>https://www.sqlbi.com/tv/handling-blank-dates-in-dax/</link>
					<comments>https://www.sqlbi.com/tv/handling-blank-dates-in-dax/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Wed, 02 Dec 2026 11:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=909270</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/FDPKYA57txw/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>Learn how to manage blank dates with the new calendar-based time intelligence. Blank dates in a semantic model force the creation of a blank row in the Date table. With new calendar time intelligence, you can better control this dummy&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/FDPKYA57txw/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>Learn how to manage blank dates with the new calendar-based time intelligence. Blank dates in a semantic model force the creation of a blank row in the Date table. With new calendar time intelligence, you can better control this dummy date.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/handling-blank-dates-in-dax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Handling blank dates in DAX</title>
		<link>https://www.sqlbi.com/articles/handling-blank-dates-in-dax/</link>
					<comments>https://www.sqlbi.com/articles/handling-blank-dates-in-dax/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Tue, 01 Dec 2026 20:00:58 +0000</pubDate>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[Tabular]]></category>
		<category><![CDATA[Data modeling]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=909323</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0313-01.png" class="webfeedsFeaturedVisual" /></figure>Blank dates in a semantic model force the creation of a blank row in the Date table. With new calendar time intelligence, you can better control this dummy date. We already talked several times about the blank row in DAX:&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0313-01.png" class="webfeedsFeaturedVisual" /></figure><p>Blank dates in a semantic model force the creation of a blank row in the Date table. With new calendar time intelligence, you can better control this dummy date.<br />
<span id="more-909323"></span></p>
<p>We already talked several times about the blank row in DAX: <a href="https://www.sqlbi.com/articles/blank-in-date-columns-and-dax-time-intelligence-functions/">here</a>, <a href="https://www.sqlbi.com/articles/blank-row-in-dax/">here</a>, and <a href="https://www.sqlbi.com/articles/understanding-blank-row-and-limited-relationships/">here</a>. The blank row is needed to accommodate invalid relationships. Its presence may be a symptom of a problem in your model, or it may exist just because of some missing data.</p>
<p>Specifically, the blank row appears in a model when the many-side of a relationship contains a value that is not present among the keys on the one side. For example, it will appear if <em>Sales</em> references a customer key that is not present in the <em>Customer</em> table.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-01.svg" width="660" /></p>
<p>However, one specific value can legitimately be present in <em>Sales</em>, and still trigger the blank row: BLANK. If a row in <em>Sales</em> contains BLANK for the customer key, Power BI creates the blank row to relate blank values with the blank row.</p>
<p>If you do not want the blank row in <em>Customer</em>, you can create a row in <em>Customer</em> with a dummy <em>CustomerKey</em> value, like -1, and replace blanks in <em>Sales</em> with -1. The main advantage of this approach is that you have control over the content of the dummy row: instead of showing blank, you can show a dummy customer name, like “&lt;NO CUSTOMER&gt;”.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-02.svg" width="660" /></p>
<p>However, there is a special scenario where this option is not available: <em>Date</em>. If you use a <em>DateTime</em> column to relate <em>Sales</em> with <em>Date</em>, the presence of BLANK in any row in <em>Sales</em> triggers the blank row in <em>Date</em>, as expected. Adding a dummy date to <em>Date</em> is not as simple as it is for <em>Customer</em> because you need a numeric value for the key (dates are stored as floating-point numbers), so you end up storing a valid date in the database, rather than a dummy date. For example, 0 as a <em>DateTime</em>, is 12/30/1899, -1 is 12/29/1899, and so on. Therefore, BLANK is not an option, as it forces the presence of the blank row; any other number is not an option either, because it is a valid date. If you want to create dummy dates in the <em>Date</em> table, then you need to revert to using an integer to create the relationship between <em>Date</em> and <em>Sales</em>. With an integer, you can use -1 as the key and BLANK in the <em>Date</em> column in the <em>Date</em> table.</p>
<p>Unfortunately, this has a nasty side effect: storing BLANK in the <em>Date</em> column prevents you from using the “Mark as a date table” feature, because the column tagged as the date column cannot contain blanks.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-03.png" width="800" /></p>
<p>The good news is that “Mark as a date table” is useful when you rely on classic time intelligence. When using Calendar-based time intelligence, “Mark as a date table” is no longer required. Be mindful that Power BI claims that “Mark as a date table” is not recommended, as you can see in the user interface above. However, “Mark as a date table” is a useful feature, and we at SQLBI recommend using it whenever you rely on classic time intelligence. When using calendar-based time intelligence, mark as a date table is just not needed.</p>
<p>Therefore, if you want to add a dummy row to <em>Date</em> to handle empty dates by yourself, rather than relying on the automatic blank row, you need <strong>both</strong>:</p>
<ul>
<li>An integer to relate any date in fact tables to the <em>Date</em> table</li>
<li>Calendar-based time intelligence rather than classic time intelligence</li>
</ul>
<p>Once these two requisites are met, you can safely add a dummy row and control how empty values are displayed. For example, in the following figure we used N/A rather than blank to show values for which the orders are not delivered yet.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-04.png" width="450" /></p>
<p>Be mindful that when <em>Date[Date]</em> contains blanks, the Power BI user interface shows errors that you can safely ignore – provided that you handle the peculiarities that appear because of that blank date, as we shall describe later on in this piece.</p>
<p>A blank date in <em>Date[Date]</em> requires special attention. In DAX, BLANK equals zero. Therefore, BLANK, as a date, is considered 12/30/1899. However, in calendar-based time intelligence, the engine does not treat the <em>Date</em> column as a date; it uses individual columns to build hierarchies in the <em>Date</em> table. In our model, dates span from 2022 to 2026. The string N/A appears later than 2026 because letters come after numbers in standard sort order. Therefore, from a DAX standpoint, N/A is a valid year that comes after 2026.</p>
<p>If a developer creates a formula like the following:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Delivery PY = 
CALCULATE ( 
    &#x5B;Delivery Amount], 
    DATEADD ( &#039;Gregorian&#039;, -1, YEAR )
)
</pre>
<p>The result is that for N/A the report will show the <em>Delivery Amount</em> of 2026, which is the year before.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-05.png" width="400" /></p>
<p>Showing 238.555,05 for <em>Delivery PY</em> in the N/A row is misleading, to say the least. Moving the N/A row to the top by sorting the <em>Year</em> column by year number solves one problem, but it introduces another. N/A as the first year would produce a value for <em>Delivery PY</em> in 2022, where we would like to see a correct blank instead.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-06.png" width="400" /></p>
<p>The easiest way to overcome this issue is to remove the dummy row from <em>Date</em> before performing any time intelligence calculation, so to make sure that the dummy row is handled in the special way it deserves:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Delivery PY Corrected = 
CALCULATE (
    CALCULATE ( 
        &#x5B;Delivery Amount], 
        DATEADD ( &#039;Gregorian&#039;, -1, YEAR ),
        KEEPFILTERS ( NOT ISBLANK ( &#039;Date&#039;&#x5B;Date] ) )
    ),
    KEEPFILTERS ( NOT ISBLANK ( &#039;Date&#039;&#x5B;Date] ) )
)
</pre>
<p>The new measure hides the value for the dummy row.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-07.png" width="500" /></p>
<p>The double filter for NOT ISBLANK is required to handle scenarios where the dummy year is at the beginning or at the end of the period. Indeed, the dummy row needs to be ignored both for the source and the destination filters created by DATEADD.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0313-08.svg" width="660" /></p>
<p>Because the pattern is likely to be used multiple times, the best option is to create a function to handle this:</p>
<div class="dax-code-title">Function</div>
<pre class="brush: dax; snippet: Function; notranslate">
 ProtectFromDummyDate = (
        formulaExpr : EXPR,
        filterExpr : EXPR
    ) =&gt;
    CALCULATE (
        CALCULATE (
            formulaExpr,
            filterExpr,
            KEEPFILTERS ( NOT ISBLANK ( &#039;Date&#039;&#x5B;Date] ) )
        ),
        KEEPFILTERS ( NOT ISBLANK ( &#039;Date&#039;&#x5B;Date] ) )
    )
</pre>
<p>This way, the measure becomes much simpler:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Delivery PY Corrected = 
    ProtectFromDummyDate ( &#x5B;Delivery Amount], DATEADD ( &#039;Gregorian&#039;, -1, YEAR ) )
</pre>
<p>This pattern can be used for any time-intelligence calculation.</p>
<h2>Conclusions</h2>
<p>The blank row is needed whenever a relationship is invalid; this includes the presence of BLANK in any row on the many-side of the relationship. Using a dummy date is not an option with classic time intelligence, whereas it becomes an opportunity with the new calendar-based time intelligence.</p>
<p>The main advantage is controlling the content and placement of the blank row; the dummy date is a custom replacement for the automatically-created blank row. One advantage of this technique is that you can define multiple dummy dates – one to indicate orders not delivered yet, one to indicate the presence of an error, and so on.</p>
<p>Although dummy dates provide more flexibility for the data modeler, they require special handling whenever you use a time intelligence calculation. Functions are very helpful here, as they let developers put complex code into a common factor and reuse it for different measures.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/handling-blank-dates-in-dax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
	</item>
		<item>
		<title>SQLBI+ roadmap: what we delayed and what is coming</title>
		<link>https://www.sqlbi.com/blog/marco/2026/11/18/sqlbi-roadmap-what-we-delayed-and-what-is-coming/</link>
					<comments>https://www.sqlbi.com/blog/marco/2026/11/18/sqlbi-roadmap-what-we-delayed-and-what-is-coming/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Wed, 18 Nov 2026 17:52:47 +0000</pubDate>
				<category><![CDATA[SQLBI+]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=blogpost&#038;p=909059</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/sqlbi-plus-roadmap-thumbnail-light.png" class="webfeedsFeaturedVisual" /></figure>We did not release much new content for SQLBI+ in the second half of 2026, and I want to apologize to our subscribers for that. The content we planned is delayed by a few months, not canceled. Now we are&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/sqlbi-plus-roadmap-thumbnail-light.png" class="webfeedsFeaturedVisual" /></figure><p>We did not release much new content for <a href="https://www.sqlbi.com/p/plus/">SQLBI+</a> in the second half of 2026, and I want to apologize to our subscribers for that. The content we planned is delayed by a few months, not canceled. Now we are back on track. We plan on catching up on the delayed 2026 pieces and on delivering the 2027 pieces as well.</p>
<p>Quick recap: this is the roadmap as of today.</p>
<table>
<thead>
<tr>
<td width="97"><strong>When</strong></td>
<td width="128"><strong>Type</strong></td>
<td width="399"><strong>Content</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td width="97">Dec 2026</td>
<td width="128">Video</td>
<td width="399">Compare different storage engines for semantic models</td>
</tr>
<tr>
<td width="97">Feb 2027</td>
<td width="128">Video course</td>
<td width="399">Inside Relationships in Semantic Models</td>
</tr>
<tr>
<td width="97">Mar 2027</td>
<td width="128">Video</td>
<td width="399">Using AI Tools to Optimize DAX</td>
</tr>
<tr>
<td width="97">Apr 2027</td>
<td width="128">Video course</td>
<td width="399">Classic and Calendar-based Time Intelligence</td>
</tr>
</tbody>
</table>
<p>The roadmap can change because of Microsoft product releases and market demand, but we will do our best to stay within these deadlines.</p>
<p>The rest of this post explains what happened, why, and what you can expect from SQLBI+, which remains a service we are committed to delivering.</p>
<h2>What happened in 2026</h2>
<p>Long story short: large language models (LLMs) became good at writing DAX code much faster than we expected, with an exponential acceleration after March 2026. That changed our priorities.</p>
<p>We spent the second half of the year creating <a href="https://www.sqlbi.com/ai">three new video courses about AI</a>: the free <a href="https://www.sqlbi.com/p/ai-for-power-bi-intro-video-course/">AI for Power BI: Intro</a>, then <a href="https://www.sqlbi.com/p/dax-with-ai-essentials-video-course/">DAX with AI: Essentials</a> and <a href="https://www.sqlbi.com/p/dax-with-ai-scenarios-video-course/">DAX with AI: Scenarios</a>. These courses could not wait: people are using AI to write DAX today, they’re not planning on starting next year.</p>
<p>Therefore, we postponed the video courses and the white papers planned for SQLBI+ by a few months: we did not change direction, we’re committed to the same volume of content, we just shifted the order of delivery.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/sqlbi-plus-roadmap-shift.svg" width="800" /></p>
<h2>What is coming</h2>
<p>In December 2026, we will publish a video session that compares the storage engines for semantic models. A semantic model can store data in VertiPaq (Import), in Delta/Parquet (Direct Lake), in DirectQuery over SQL, or in a composite model. We analyze these engines and compare their performance and costs.</p>
<p>In February 2027, we will release the first of two new SQLBI+ video courses: Inside Relationships in Semantic Models. It covers all relationship types available in Power BI semantic models and their performance implications. For example, it explains what changes when you use a relationship in a DirectQuery model or in a composite model.</p>
<p>In March 2027, AI will come back in a video session, this time for performance: Using AI Tools to Optimize DAX. Tools like the Power BI Modeling MCP Server (MCP stands for Model Context Protocol) enable AI tools to test the execution performance of a query. This supports the iteration required to optimize DAX: create a baseline, apply a change, verify that the results are the same, and compare performance.</p>
<p>In April 2027, we shall release the second video course: Classic and Calendar-based Time Intelligence. It is a broader course, and we want it to be the reference with all the details you usually don't find in articles: a complete guide to managing the corner cases you might encounter.</p>
<p>We will also add other video sessions to the roadmap.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/sqlbi-plus-roadmap-timeline.svg" width="800" /></p>
<h2>The SQLBI+ approach</h2>
<p>Historically, SQLBI produced free content to promote the brand and to sell more advanced training. The SQLBI business model relied on a small number of paying customers funding content available to everyone.</p>
<p>SQLBI+ started with a different idea: a subscription that funds the production of niche content that would be impossible to sell as individual mini-courses. For example, the white paper and video course about security in semantic models is extremely valuable the day you need it, but it would be hard to sell as an individual course. If it is part of a library, you get the value from the immediate access whenever you need it.</p>
<p>The SQLBI+ model remains valuable: we renew our commitment, and we closely monitor our subscriber retention. As long as the subscriber base sustains this work, we will continue producing content that would not be available otherwise.</p>
<p>We are looking into adapting the website to how agents and humans consume our content. However, the principle remains that SQLBI+ subscribers will continue to have access to that content through their agents as well.</p>
<p>The only thing SQLBI+ does not include is access to our other video courses. The longer courses, such as Mastering DAX and the new AI courses, remain available for individual purchase. SQLBI+ has always been an add-on to that: an advanced library of content for professional developers.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/sqlbi-plus-content-model.svg" width="800" /></p>
<h2>Subscription value</h2>
<p>The price of SQLBI+ is not based on the quantity of content we release every year. It is based on the value of having access to an exclusive library of content whenever you need it.</p>
<p>Besides, this is not a new idea. When we <a href="https://www.sqlbi.com/articles/welcome-to-sqlbi-plus/">launched SQLBI+</a>, we said the goal was to save you research and testing time, and that we expect an advanced user to find one or two pieces of content every year that make a real difference in their work.</p>
<p>For example, imagine you have a performance issue in a composite model. You can spend many hours, if not days, researching and testing, or you can watch a session to review the underlying behavior of the feature and understand the bottleneck you are facing. If you translate the time spent on trial and error into lost revenue, you may find it is a multiple of the SQLBI+ yearly subscription.</p>
<h2>Our commitment</h2>
<p>We made commitments about the content releases for SQLBI+, and we will fulfill them. We will catch up very soon with what was delayed.</p>
<p>The form of these commitments could change in the future, because the way people and their tools use content is changing. If we must change our commitments, the rule we follow is that a change must give subscribers more value, not less. We will also give enough notice so that you can judge the change before your next renewal.</p>
<p>I prefer to underpromise and overdeliver. The roadmap above includes only what we are ready to commit to today, and we will update it when we add more content.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/blog/marco/2026/11/18/sqlbi-roadmap-what-we-delayed-and-what-is-coming/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Introducing full text search for DAX</title>
		<link>https://www.sqlbi.com/tv/introducing-full-text-search-for-dax/</link>
					<comments>https://www.sqlbi.com/tv/introducing-full-text-search-for-dax/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Tue, 17 Nov 2026 11:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=908406</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/IBfK77ka1Cc/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>How to enable full-text indexing in Power BI and search text with the TEXTCONTAINS and TEXTSIMILARITY functions.]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/IBfK77ka1Cc/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>How to enable full-text indexing in Power BI and search text with the TEXTCONTAINS and TEXTSIMILARITY functions.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/introducing-full-text-search-for-dax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Introducing full-text search for DAX</title>
		<link>https://www.sqlbi.com/articles/introducing-full-text-search-for-dax/</link>
					<comments>https://www.sqlbi.com/articles/introducing-full-text-search-for-dax/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Mon, 16 Nov 2026 20:00:15 +0000</pubDate>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[Optimization]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=908067</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0312-01.png" class="webfeedsFeaturedVisual" /></figure>This article describes how to enable full-text indexing in a Power BI semantic model and how to search text with the TEXTCONTAINS and TEXTSIMILARITY functions. Searching text in a Power BI report usually means looking for a string inside the&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0312-01.png" class="webfeedsFeaturedVisual" /></figure><p>This article describes how to enable full-text indexing in a Power BI semantic model and how to search text with the TEXTCONTAINS and TEXTSIMILARITY functions.<br />
<span id="more-908067"></span></p>
<p>Searching text in a Power BI report usually means looking for a string inside the values of a column. For example, the filter pane translates a "contains" condition into a DAX expression based on <a href="https://dax.guide/containsstring/">CONTAINSSTRING</a> or <a href="https://dax.guide/search/">SEARCH</a>, which look for a sequence of characters anywhere in the text; for example, a search for "phone" also returns "headphones" and "microphone".</p>
<p>With a full-text index, search functions operate on words rather than characters. The text data is divided into words, also called tokens, and a following text-normalization technique called stemming reduces words to their root form. For example, “running” and “runs” both stem to “run”, whereas “runner” remains a different word. This way, a search for "phone" can return "phones", but not "headphones", because it has a different meaning. Also, full-text search can tolerate typos and rank results by relevance, which CONTAINSSTRING cannot do.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-01.svg" width="800" /></p>
<p>Power BI semantic models can build a full-text index on string columns; the feature was introduced in preview in September 2026. Two DAX functions use the index: <a href="https://dax.guide/textcontains/">TEXTCONTAINS</a> checks whether any text matches the search, and <a href="https://dax.guide/textsimilarity/">TEXTSIMILARITY</a> returns a relevance score.</p>
<p>In this article, we describe how to enable the index, how the two functions work, and how to use them in a report. If you need to improve the performance of CONTAINSSTRING and SEARCH without a full-text index, read <a href="https://www.sqlbi.com/articles/optimizing-text-search-in-dax/">Optimizing text search in DAX</a>.</p>
<h2>Enabling the full-text index on a column</h2>
<p>The full-text index is controlled by a column property named <em>fullTextIndexingBehavior</em>. The property requires a model with compatibility level 1708 or higher. It applies only to string columns of tables in Import, Dual, or Direct Lake storage modes. The <a href="https://learn.microsoft.com/en-us/analysis-services/azure-analysis-services/full-text-indexing?view=power-bi-premium-current">Microsoft documentation</a> describes all the details. Here, we focus on the steps required to run the examples in this article.</p>
<p>The property has three possible values:</p>
<ul>
<li><strong>Full</strong>: the engine builds the index every time the table is processed. This is the choice we use in this article.</li>
<li><strong>Explicit</strong>: the engine builds the index only when an indexes refresh is explicitly triggered through the XMLA endpoint.</li>
<li><strong>Off</strong>: the engine does not build the index. Any query that uses TEXTCONTAINS or TEXTSIMILARITY on the column returns an error.</li>
</ul>
<p>The index increases memory usage and the time it takes to refresh the semantic model. Therefore, you should enable this option only for columns where full-text search can be helpful, such as a product description or the text of a support ticket.</p>
<p><strong>NOTE</strong>: the “Full Text Indexing Behavior” property shows the same settings as “String Indexing Behavior”, which also includes an “Auto” value for a lazy index executed on the first request. However, the “Auto” value is not supported for “Full Text Indexing Behavior”.</p>
<h3>Using the TMDL view</h3>
<p>The documentation describes the configuration in the <a href="https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-tmdl-view">TMDL view</a> of Power BI. These are the steps:</p>
<ol>
<li>Open the semantic model in the Power BI service and select TMDL view.</li>
<li>Drag the table that contains the column onto the TMDL canvas, so that the TMDL view generates a script with its definition.</li>
<li>Add the <em>fullTextIndexingBehavior</em> property to the column.</li>
<li>Apply the change in Edit mode. Because the property requires compatibility level 1708, the TMDL view asks to upgrade the model.</li>
<li>Refresh the semantic model to build the index.</li>
</ol>
<p>The following excerpt shows only the relevant lines of the Product Name column after the change:</p>
<pre class="brush: plain; notranslate">
table Product
    column &#039;Product Name&#039;
        dataType: string
        fullTextIndexingBehavior: full
</pre>
<p>It is important to add the property to the script generated by the TMDL view, rather than writing a new script with only these lines. The script starts with <em>createOrReplace</em>, which replaces the entire table. Indeed, a column or a property missing in the script would be removed from the model:</p>
<pre class="brush: plain; notranslate">
createOrReplace

    ref table Product

        column &#039;Product Name&#039;
            dataType: string
            fullTextIndexingBehavior: full
            summarizeBy: none
            sourceColumn: Product Name

            annotation SummarizationSetBy = Automatic
            annotation PBI_FormatHint = {&quot;isText&quot;:true}
</pre>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-02.png" width="550" /></p>
<h3>Using Tabular Editor</h3>
<p>Tabular Editor can set the same property through the XMLA endpoint, and <a href="https://github.com/TabularEditor/TabularEditor/releases/tag/2.29.0">Tabular Editor 2</a> (the free version of Tabular Editor) supports it starting from version 2.29.0. After connecting to the semantic model, we set the compatibility level of the model to 1708. Then, we set the <em>FullTextIndexingBehavior</em> property of the column to Full. Saving the changes updates the model in the Power BI service, and a refresh of the table builds the index.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-03.png" width="550" /></p>
<p>The Power BI user interface does not show whether the index exists. The simplest check is a query that uses TEXTCONTAINS on the column. The query returns an error if there is no index:</p>
<blockquote><p>Full-text index is not available. Set the column's 'fullTextIndexingBehavior' property to 'Full' and process the model to build the index.</p></blockquote>
<h2>Searching words with TEXTCONTAINS</h2>
<p>TEXTCONTAINS returns TRUE when the text in a column matches the search text, and FALSE otherwise. The first argument must be a column with a full-text index, and the second argument is the text to search. The optional, third argument defines the match mode, which we describe later in this section:</p>
<pre class="brush: dax; notranslate">
TEXTCONTAINS ( &lt;WithinTextColumn&gt;, &lt;SearchText&gt; &#x5B;, &lt;MatchMode&gt;] )
</pre>
<p>The simplest way to see the difference from CONTAINSSTRING is to use both functions on the same column. The following query returns the product names that contain the string "phone". It also adds a column with the result of TEXTCONTAINS for the same search:</p>
<div class="dax-code-title">Query</div>
<pre class="brush: dax; snippet: Query; notranslate">
EVALUATE
ADDCOLUMNS (
    FILTER (
        VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
        CONTAINSSTRING ( &#039;Product&#039;&#x5B;Product Name], &quot;phone&quot; )
    ),
    &quot;Word match&quot;, TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;phone&quot; )
)
ORDER BY
    &#x5B;Word match] DESC,
    &#039;Product&#039;&#x5B;Product Name] DESC
</pre>
<p>CONTAINSSTRING returns all the names that include the characters "phone", like the names of headphones. TEXTCONTAINS returns TRUE only for the names that contain the word "phone", or another form of the same word, that points to the same actual meaning, like "phones".</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-04.png" width="800" /></p>
<p>The default match mode is TEXTMATCHING. TEXTMATCHING splits the search text into words, and it returns TRUE when the text contains at least one of them. This might not be what users expect: a search for "digital camera" also returns names that contain only "digital" or only "camera".</p>
<p>The PHRASEMATCHING mode returns TRUE only when the words are next to each other, in the same order as in the search text. When all the words must be present in any order, the solution is to combine several TEXTCONTAINS calls with the &amp;&amp; operator. The following query compares the number of products found with each technique:</p>
<div class="dax-code-title">Query</div>
<pre class="brush: dax; snippet: Query; notranslate">
EVALUATE
ROW (
    &quot;Any word&quot;,
        COUNTROWS (
            FILTER ( &#039;Product&#039;, TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;digital camera&quot; ) )
        ),
    &quot;All words&quot;,
        COUNTROWS (
            FILTER (
                &#039;Product&#039;,
                TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;digital&quot; )
                    &amp;&amp; TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;camera&quot; )
            )
        ),
    &quot;Phrase&quot;,
        COUNTROWS (
            FILTER (
                &#039;Product&#039;,
                TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;digital camera&quot;, PHRASEMATCHING )
            )
        )
)
</pre>
<p>The number of products decreases from the first column to the last. For example, “Contoso Leather Case - case for digital photo camera X20 Black” includes both words, but not the phrase "digital camera". The three leather cases for digital photo cameras are the only difference between the second and the third column.</p>
<table>
<tbody>
<tr>
<td><strong>Any word</strong></td>
<td><strong>All words</strong></td>
<td><strong>Phrase</strong></td>
</tr>
<tr>
<td>238</td>
<td>118</td>
<td>115</td>
</tr>
</tbody>
</table>
<p>The FUZZYMATCHING mode tolerates small differences between the words of the text and the words of the search, such as typos. For example, the following query finds the cameras even though the search text is misspelled:</p>
<div class="dax-code-title">Query</div>
<pre class="brush: dax; snippet: Query; notranslate">
EVALUATE
FILTER (
    VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
    TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;camra&quot;, FUZZYMATCHING )
)
</pre>
<p>Fuzzy matching is useful when the search text comes from a user. However, it can also return words similar to the search text that are not related. Therefore, it is a good idea to test it with real user searches. For example, searching for “cmera” returns only the 223 camera products. Instead, “camra”, which we used in the sample query, returns 291 products: besides the cameras, the result includes 68 unrelated products, such as car power adapters, car video systems, network card adapters, and carrying cases.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-05.png" width="550" /></p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-06.svg" width="800" /></p>
<p>The search is not case-sensitive, but it is accent-sensitive: for example, “café” does not match “cafe”. Text normalization also depends on the semantic model language property, which cannot be set at the column level. For example, with an English model, a search for "run" also matches "running", whereas common words like "the" and "of" are ignored. These common words are called stop words. A search text made only of stop words does not return FALSE: the query fails with the following error. For example, this happens with “the” or “of the”, both in TEXTCONTAINS and in TEXTSIMILARITY. This is important when the search text comes from a user input.</p>
<blockquote><p>Full-text query failed for column '' of table '': no tokens after analysis</p></blockquote>
<p>If the model language is English and you have a column with product names in Italian, the engine applies English rules to Italian words, thereby lowering the quality of full-text search results.</p>
<p>Stop words also affect PHRASEMATCHING. A phrase that includes a stop word does not match the text, even when the text contains exactly the same words. For example, six product names contain “Adapter for Contoso”, but a PHRASEMATCHING search for “adapter for contoso” does not return any of them. We obtained the same result with “games for kids” and “transmitter and bluetooth”, whereas phrases without stop words, like “hand games”, return all the products that contain them. Removing the stop word from the search text does not help either: “adapter contoso” does not match those names. In that case, the only option is to combine several TEXTCONTAINS calls with the &amp;&amp; operator, as we have seen for “digital” and “camera”.</p>
<h2>Ranking results with TEXTSIMILARITY</h2>
<p>TEXTSIMILARITY has the same arguments as TEXTCONTAINS, including the match mode. However, instead of TRUE or FALSE, it returns a relevance score. So a higher value means a better match, and zero means the text does not match the search:</p>
<pre class="brush: dax; notranslate">
TEXTSIMILARITY ( &lt;WithinTextColumn&gt;, &lt;SearchText&gt; &#x5B;, &lt;MatchMode&gt;] )
</pre>
<p>The following query computes the score of each product name for the search text "red refrigerator". It returns only the names with a score greater than zero, sorted by score:</p>
<div class="dax-code-title">Query</div>
<pre class="brush: dax; snippet: Query; notranslate">
DEFINE
    VAR SearchText = &quot;red refrigerator&quot;

EVALUATE
FILTER (
    ADDCOLUMNS (
        VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
        &quot;Score&quot;, TEXTSIMILARITY ( &#039;Product&#039;&#x5B;Product Name], SearchText )
    ),
    &#x5B;Score] &gt; 0
)
ORDER BY &#x5B;Score] DESC
</pre>
<p>Because the default match mode is TEXTMATCHING, the result includes every product that contains red or refrigerator. The red refrigerators appear at the top of the list, followed by other refrigerators and then other red products.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-07.png" width="650" /></p>
<p>A common requirement is to make one word mandatory and to use the other words only to sort the results. In that case, TEXTCONTAINS filters the rows, and TEXTSIMILARITY ranks them, as in the following query:</p>
<div class="dax-code-title">Query</div>
<pre class="brush: dax; snippet: Query; notranslate">
DEFINE
    VAR SearchText = &quot;red refrigerator&quot;

EVALUATE
ADDCOLUMNS (
    FILTER (
        VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
        TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;refrigerator&quot; )
    ),
    &quot;Score&quot;, TEXTSIMILARITY ( &#039;Product&#039;&#x5B;Product Name], SearchText )
)
ORDER BY &#x5B;Score] DESC
</pre>
<p>The result contains only refrigerators, with the red ones at the top. The result of TEXTSIMILARITY does not depend on the rows filtered: in other words, each refrigerator gets the same score as in the previous query, even though we reduced the number of product names returned.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-08.png" width="700" /></p>
<h2>Reading the similarity score</h2>
<p>The score returned by TEXTSIMILARITY is a value that does not mean much by itself. A score of 3 is not good or bad in itself. It only says that the row is more relevant than a row with a score of 2 in the same search. The documentation is explicit: scores are not comparable across different search strings or different columns.</p>
<p>The reason is the algorithm: TEXTSIMILARITY returns a score based on a ranking algorithm that assigns a weight to each word of the search text. Words that appear in fewer texts get a higher weight because they are more selective. Also, a word repeated in the same text adds less to the score each time. Moreover, a text with fewer words gets a higher score than a text with more words that matches the same search words. The number of characters does not matter, and stop words are not counted. Microsoft does not document the algorithm, but the scores we obtained are consistent with the <a href="https://en.wikipedia.org/wiki/Okapi_BM25">BM25</a> formula with its most common parameters.</p>
<p>The weight of each word depends on the content of the entire column. As a consequence, the same product name can get a different score after a refresh that adds new products. For this reason, comparing scores computed at different times also does not make sense.</p>
<p>What matters is the distance between the rows of the same result. The following query groups the products found by the search stored in <em>ProductScores</em> according to the words they contain (“red” and “refrigerator”):</p>
<div class="dax-code-title">Query</div>
<pre class="brush: dax; snippet: Query; notranslate">
DEFINE
    VAR SearchText = &quot;red refrigerator&quot;
    VAR ProductScores =
        ADDCOLUMNS (
            VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
            &quot;Score&quot;, TEXTSIMILARITY ( &#039;Product&#039;&#x5B;Product Name], SearchText ),
            &quot;Contains red&quot;, TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;red&quot; ),
            &quot;Contains refrigerator&quot;, TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], &quot;refrigerator&quot; )
        )

EVALUATE
GROUPBY (
    FILTER ( ProductScores, &#x5B;Score] &gt; 0 ),
    &#x5B;Contains red],
    &#x5B;Contains refrigerator],
    &quot;Products&quot;, SUMX ( CURRENTGROUP (), 1 ),
    &quot;Min Score&quot;, MINX ( CURRENTGROUP (), &#x5B;Score] ),
    &quot;Max Score&quot;, MAXX ( CURRENTGROUP (), &#x5B;Score] )
)
ORDER BY &#x5B;Max Score] DESC
</pre>
<p>For each group, it shows the number of products and the score range.</p>
<table>
<tbody>
<tr>
<td><strong>Contains red</strong></td>
<td><strong>Contains refrigerator</strong></td>
<td><strong>Products</strong></td>
<td><strong>Min Score</strong></td>
<td><strong>Max Score</strong></td>
</tr>
<tr>
<td>true</td>
<td>true</td>
<td>2</td>
<td>6.88</td>
<td>7.35</td>
</tr>
<tr>
<td>false</td>
<td>true</td>
<td>84</td>
<td>3.51</td>
<td>4.03</td>
</tr>
<tr>
<td>true</td>
<td>false</td>
<td>97</td>
<td>2.82</td>
<td>3.86</td>
</tr>
</tbody>
</table>
<p>The products with both words have the highest scores. With the same number of words, a product that contains only “refrigerator” scores higher than a product that contains only “red”, because “red” appears in more product names (99 instead of 86) and is less selective. However, the groups overlap, because the score also depends on the number of words in the product name. For example, “Fabrikam Laptop12 M2002 Red” has four words and a score of 3.86, which is higher than the 3.75 of “Litware Refrigerator 19CuFt M760 Green”, which has five words. Overall, 10 products that contain only “red” rank above 69 of the 84 products that contain only “refrigerator”.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-09.svg" width="800" /></p>
<p>Therefore, we do not recommend showing the raw score to the users. The position in the ranking is easier to read, and so is a relative score. A relative score is the score of each row divided by the highest score for the same search:</p>
<div class="dax-code-title">Query</div>
<pre class="brush: dax; snippet: Query; notranslate">
DEFINE
    VAR SearchText = &quot;red refrigerator&quot;
    VAR ProductScores =
        ADDCOLUMNS (
            VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
            &quot;Score&quot;, TEXTSIMILARITY ( &#039;Product&#039;&#x5B;Product Name], SearchText )
        )
    VAR TopScore =
        MAXX ( ProductScores, &#x5B;Score] )

EVALUATE
ADDCOLUMNS (
    FILTER ( ProductScores, &#x5B;Score] &gt; 0 ),
    &quot;Relative Score&quot;, DIVIDE ( &#x5B;Score], TopScore )
)
ORDER BY &#x5B;Score] DESC
</pre>
<p>The relative score is 1 (100%) for the best match, and it shows how far each row is from the best match. Like the original score, it only makes sense within one same search.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-10.png" width="700" /></p>
<h2>Using full-text search in Power BI reports</h2>
<p>At the time of writing, no Power BI visual uses the full-text index. For example, the filter pane still translates a "contains" condition into CONTAINSSTRING or SEARCH, so it keeps searching characters instead of words. Therefore, TEXTCONTAINS and TEXTSIMILARITY are mainly useful in DAX code written by a developer.</p>
<p>The first scenario is a custom application that runs DAX queries. For example, a Power BI Embedded application can receive the search text from the user and run a query with TEXTSIMILARITY. The query returns the keys of the best matches, which the application applies as a filter to the embedded report.</p>
<p>Calculated columns and calculated tables are not a good fit for a dynamic search. As we describe in the “Current limitations of the preview” section, they can only use a literal search text. For example, they cannot match the product names with a list of keywords stored on another table.</p>
<p>The second scenario is a report that uses a measure. A measure can evaluate TEXTSIMILARITY for each product in a visual and work as a visual-level filter. The search text can come from a disconnected table with a list of searches, selected through a slicer.</p>
<p>We see here the definitions of the table and measure used:</p>
<div class="dax-code-title">Calculated table</div>
<pre class="brush: dax; notranslate">
Search Terms =
DATATABLE (
    &quot;Search Text&quot;, STRING,
    {
        { &quot;red refrigerator&quot; },
        { &quot;digital camera&quot; },
        { &quot;home theater&quot; }
    }
)
</pre>
<div class="dax-code-title">Measure in Product table</div>
<pre class="brush: dax; snippet: Measure; table: Product; notranslate">
Search Score =
VAR SearchText =
    SELECTEDVALUE ( &#039;Search Terms&#039;&#x5B;Search Text] )
RETURN
    IF (
        NOT ISBLANK ( SearchText ),
        MAXX (
            VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
            TEXTSIMILARITY ( &#039;Product&#039;&#x5B;Product Name], SearchText )
        )
    )
</pre>
<p>In a table visual showing the product name, the <em>Search Score</em> measure returns the score of each product. A visual-level filter keeps only the products where <em>Search Score</em> is greater than zero, which removes the products that do not match the search. We can show the best matches first by sorting the visual by <em>Search Score</em>.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-11.png" width="800" /></p>
<p>There are two limitations to using this technique. First, the filter works only at the visual level, because Power BI does not accept measures in page-level or report-level filters. Second, users can choose only one search from the slicer, which shows the values in the disconnected table.</p>
<p>We can use a different approach by moving the search inside a measure instead of using a visual filter. For example, the following measure computes <em>Sales Amount</em> only for the products filtered by the <em>Search Text</em> selection:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Sales Amount Found =
VAR SearchText =
    SELECTEDVALUE ( &#039;Search Terms&#039;&#x5B;Search Text] )
RETURN
    IF (
        ISBLANK ( SearchText ),
        &#x5B;Sales Amount],
        CALCULATE (
            &#x5B;Sales Amount],
            FILTER (
                VALUES ( &#039;Product&#039;&#x5B;Product Name] ),
                TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], SearchText )
            )
        )
    )
</pre>
<p>Any visual that uses it responds to the search, including a chart by category. If the slicer has no selection, the measure returns the <em>Sales Amount</em> of all products. However, this approach also limits users to one selection from the disconnected table.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-12.png" width="800" /></p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0312-13.png" width="800" /></p>
<h2>Current limitations of the preview</h2>
<p>Full-text indexing is in preview with several limitations. These are the most relevant at the time of writing:</p>
<ul>
<li>The feature is documented for Power BI semantic models, not for SQL Server Analysis Services nor Azure Analysis Services.</li>
<li>The configuration requires the TMDL view of the Power BI service or a tool like Tabular Editor connected through the XMLA endpoint, because there is no graphical property editor.</li>
<li>The index refresh required by the explicit behavior is available only through the XMLA endpoint, not in the refresh of the Power BI service or in the REST API.</li>
<li>The index supports only string columns in tables with Import, Dual, or Direct Lake storage modes. DirectQuery tables are not supported.</li>
<li>Only 18 languages have stemming and stop-word removal, including English, French, German, Italian, and Spanish.</li>
<li>TEXTCONTAINS and TEXTSIMILARITY are evaluated row by row. Before using them in a calculated column in a large table, you should test the performance.</li>
<li>There is no user interface that confirms whether the index exists.</li>
<li>During the preview, the capacity units (CU) consumed to build the index are not fully tracked, so the reported consumption might increase at general availability.</li>
<li>With Direct Lake, the automatic synchronization of the data can take longer when the index is enabled.</li>
</ul>
<p>At the time of writing, the documentation does not mention another restriction: the search text must be the same for the entire query. You can use a literal string or a measure that reads the selection of a slicer with SELECTEDVALUE.</p>
<p>The search text cannot change within the same query. It fails when it depends on the current row of an iteration, even through a variable or CALCULATE. It also fails when it depends on a column grouped by SUMMARIZECOLUMNS, like the rows of a matrix. For example, the following calculated column in a <em>Keywords</em> table fails because the keyword changes for each row of the table:</p>
<div class="dax-code-title">Calculated column in Keywords table</div>
<pre class="brush: dax; table: Keywords; notranslate">
Matching Products =
VAR CurrentKeyword = Keywords&#x5B;Keyword]
RETURN
    COUNTROWS (
        FILTER ( &#039;Product&#039;, TEXTCONTAINS ( &#039;Product&#039;&#x5B;Product Name], CurrentKeyword ) )
    )
</pre>
<p>The same error happens with a calculated table that matches a list of keywords with the product names. In practice, calculated columns and calculated tables can use TEXTCONTAINS and TEXTSIMILARITY only with a literal search text:</p>
<blockquote><p>The function 'TEXTCONTAINS' expects its argument number 2 to be constant.</p></blockquote>
<h2>Conclusions</h2>
<p>The full-text index in Power BI enables word-based search in specific columns of the semantic model. TEXTCONTAINS finds the rows that contain words, phrases, or similar words, whereas TEXTSIMILARITY ranks the rows by relevance. In the preview, Power BI does not provide visuals that use these functions, but these functions are already available in DAX measures to customize filters and visualizations in existing visuals.</p>
<p>You should enable the full-text index only on the columns where users will actually perform searches, in order to reduce the refresh time and improve query performance.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/introducing-full-text-search-for-dax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
	</item>
		<item>
		<title>Opening your Microsoft Whiteboard boards in SQLBI Whiteboard</title>
		<link>https://www.sqlbi.com/blog/marco/2026/11/14/opening-your-microsoft-whiteboard-boards-in-sqlbi-whiteboard/</link>
					<comments>https://www.sqlbi.com/blog/marco/2026/11/14/opening-your-microsoft-whiteboard-boards-in-sqlbi-whiteboard/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Sat, 14 Nov 2026 08:00:12 +0000</pubDate>
				<guid isPermaLink="false">https://www.sqlbi.com/?post_type=blogpost&#038;p=907594</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/opening-ms-whiteboard-thumbnail.png" class="webfeedsFeaturedVisual" /></figure>Microsoft retired the standalone Microsoft Whiteboard apps on October 16, 2026. You can now use the web version only with a work account; with a personal Microsoft account, you cannot use it at all. Boards not exported from your personal&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/opening-ms-whiteboard-thumbnail.png" class="webfeedsFeaturedVisual" /></figure><p>Microsoft retired the standalone Microsoft Whiteboard apps on October 16, 2026. You can now use the web version only with a work account; with a personal Microsoft account, you cannot use it at all. Boards not exported from your personal account before October 16, 2026 were permanently deleted; if you have a work account, you can still export boards stored in your OneDrive.</p>
<p><img decoding="async" class="nozoom" style="float: right;margin: 0 0 10px 10px;border: none !important" src="https://www.sqlbi.com/wp-content/uploads/SQLBI.Whiteboard.svg" alt="SQLBI Whiteboard (logo)" width="150" />Alberto and I use a whiteboard every day for our videos, and we prefer an app that works offline (if you run a training, you cannot rely on an internet connection), and the retirement announcement came up in the middle of recording our new DAX with AI courses. So, in August, we built our own: <a href="https://whiteboard.sqlbi.com/">SQLBI Whiteboard</a>. It is free, open source, and runs on Windows. It doesn't require an account or a tenant, and it saves your boards on your machine. You have probably already seen it in our latest videos.</p>
<h2>Open the boards you exported</h2>
<p>If you export your boards as ZIP files (Settings → Export → Zip (HTML+JSON)), you can open them with SQLBI Whiteboard.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/opening-ms-whiteboard-01.png" alt="Microsoft Whiteboard: Settings, Export, Zip (HTML+JSON)" width="800" /></p>
<p>Install SQLBI Whiteboard from the <a href="https://apps.microsoft.com/detail/9NN5N0L2TMTF">Microsoft Store</a>, or with a single command:</p>
<pre><code>winget install SQLBI.Whiteboard</code></pre>
<p>Then use File → Open and select the ZIP file: you get a new board with its ink, notes, shapes, and text. Just save it as a <code>.wboard</code> file, and you can continue to work on the whiteboard with your data.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/opening-ms-whiteboard-02.png" alt="A ZIP exported from Microsoft Whiteboard opened with File, Open in SQLBI Whiteboard" width="800" /></p>
<p>If you want to add the content of an exported ZIP to an existing board, use File → Import, or drop the ZIP onto the board. The <a href="https://whiteboard.sqlbi.com/export-microsoft-whiteboard.html">export guide</a> describes the details of the operation.</p>
<h2>Not just a replacement</h2>
<p>We initially designed SQLBI Whiteboard as a teaching tool, mainly to highlight and annotate existing material rather than create new diagrams from scratch. However, we later added features to support importing from Microsoft Whiteboard, so today it fully replaces the retired Microsoft application.</p>
<p>SQLBI Whiteboard supports pen, touch, and mouse, and exports to PDF and PPTX. The LiveView feature shows a live view of any other window or screen inside the board, so you can draw on a running application, even when it is hidden behind other windows! The <a href="https://whiteboard.sqlbi.com/guide.html">guide page</a> shows every feature in action.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/opening-ms-whiteboard-03.png" alt="SQLBI Whiteboard annotating a Power BI matrix and its DAX code" width="800" /></p>
<p>We tested the import with many files created in Microsoft Whiteboard, but we couldn't test every combination. If a board does not import correctly, please <a href="https://github.com/sql-bi/SQLBI-Whiteboard/issues">open an issue</a> and attach the ZIP file, if you can share it.</p>
<p>How did two people build a complete whiteboard app during an Italian August holiday? That is a longer story about building software with AI, and <a href="https://marcorusso.com/writing/maximum-valuable-product/">I wrote it on my personal blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/blog/marco/2026/11/14/opening-your-microsoft-whiteboard-boards-in-sqlbi-whiteboard/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Inside DAXBench v2: Results and Your Questions</title>
		<link>https://www.sqlbi.com/tv/inside-daxbench-v2-results-and-your-questions/</link>
					<comments>https://www.sqlbi.com/tv/inside-daxbench-v2-results-and-your-questions/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Wed, 04 Nov 2026 17:52:38 +0000</pubDate>
				<guid isPermaLink="false">https://www.sqlbi.com/tv/inside-daxbench-v2-results-and-your-questions/</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/WzWYiTaj8mM/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>How well do AI models write DAX? DAXBench is a public leaderboard that tests AI models on DAX tasks. Version 2 uses a new set of tasks that run against prepared Power BI models. In this webinar, Marco Russo (SQLBI)&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/WzWYiTaj8mM/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>How well do AI models write DAX? DAXBench is a public leaderboard that tests AI models on DAX tasks. Version 2 uses a new set of tasks that run against prepared Power BI models.</p>
<p>In this webinar, Marco Russo (SQLBI) and Maxim Anatsko explained how they built v2, commented on the results, and answered attendees' questions during the session.</p>
<p>Marco and Maxim replied to questions posted in the chat during the live stream.</p>
<p>Recorded on Wednesday, November 4, 2026, at 16:00 CET.</p>
<p>Links:<br />
- DAXBench leaderboard: https://www.daxbench.com/<br />
- Blog post: https://www.sqlbi.com/blog/marco/2026/10/27/dax-llm-benchmark-v2/<br />
- How DAXBench works: https://www.maxanatsko.com/blog/daxbench-road-to-v2</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/inside-daxbench-v2-results-and-your-questions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Optimizing DAX with AI</title>
		<link>https://www.sqlbi.com/tv/optimizing-dax-with-ai/</link>
					<comments>https://www.sqlbi.com/tv/optimizing-dax-with-ai/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Wed, 04 Nov 2026 10:55:14 +0000</pubDate>
				<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=907882</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/F52wwF9IiKk/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>Can AI optimize a DAX expression? Sure, it can. However, when AI and humans work together, the result is better.]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/F52wwF9IiKk/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>Can AI optimize a DAX expression? Sure, it can. However, when AI and humans work together, the result is better.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/optimizing-dax-with-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Optimizing DAX with AI</title>
		<link>https://www.sqlbi.com/articles/optimizing-dax-with-ai/</link>
					<comments>https://www.sqlbi.com/articles/optimizing-dax-with-ai/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Mon, 02 Nov 2026 20:00:41 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Optimization]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=907851</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0311-06-query-duration-chart.svg" class="webfeedsFeaturedVisual" /></figure>Can AI optimize a DAX expression? Sure, it can. However, when AI and humans work together, the result is better. In this article, we show a simple example. NOTE: The solution in the video differs from the one in the&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0311-06-query-duration-chart.svg" class="webfeedsFeaturedVisual" /></figure><p>Can AI optimize a DAX expression? Sure, it can. However, when AI and humans work together, the result is better. In this article, we show a simple example.<br />
<span id="more-907851"></span><br />
<strong>NOTE: The solution in the video differs from the one in the article. We suggest comparing the article and video solutions to see how the same problem can yield different responses with the same context and prompts.</strong></p>
<p>The debate over whether AI will replace human work is heating up. However, our vision is different: AI is not a replacement; it is a powerful tool, and when AI and humans work together on a problem, the outcome is better than when either works on their own.</p>
<p>Optimizing DAX is a fascinating task. However, in the process of optimizing DAX, you need to pay attention to several details:</p>
<ul>
<li>The new formula needs to be equivalent to the old one; this requires extensive testing.</li>
<li>The shape of the query being executed matters: a formula may be better than another in a specific test, but not in others.</li>
<li>The data distribution matters: a database with 100K customers and 100M transactions requires a different optimization compared to one with 10K customers and 10B transactions.</li>
</ul>
<p>The fascinating part is in finding new ways to express the same algorithm. All the details are quite boring, and it is easy to make mistakes because you need to run many tests. The good thing about AI is that it can generate and run tests for you, collect the results, and prepare reports that help you better understand whether a new formula is a good replacement for the old one. For this type of task, AI is a great assistant.</p>
<p>However, this article investigates a different question. Can AI optimize a DAX formula well? Optimizing requires specific skills: a certain knowledge of the DAX engine, the ability to generate different versions of the same algorithm, and a bit of creativity to test ideas that may look unorthodox but turn out to be smart in the complex world of columnar databases.</p>
<p>This article is not a complete paper about how effective AI can be at optimizing DAX. We tested a simple formula and drew some initial conclusions. Your mileage may vary, and things will change quickly as new LLMs emerge. However, in its simplicity, the article draws a simple idea:</p>
<p>AI can optimize DAX code, like a good developer. However, AI can produce better results when a human guides it toward new ideas. AI can further refine those ideas, and human-AI interaction can produce strong results.</p>
<p>When it is time to test AI, there is a subtle problem: if we ask it to optimize a formula we have already written, AI has seen it and is likely to find similar examples and adapt them to the new task. So, we needed an exotic calculation unlikely to appear online.</p>
<p>Here is an excerpt of the contract. You can find the full contract in the download content of this article.</p>
<table>
<tbody>
<tr>
<td width="582">
<h2>Repeat purchase sales contract</h2>
<p>Create a DAX measure named Repeat Purchase Sales. It returns sales made on purchase days that occur within 30 calendar days of the same customer’s immediately preceding purchase day.</p>
<h2>Purchase days and qualification</h2>
<p>Evaluate customers independently, using CustomerKey as their identity.</p>
<p>A purchase day is a distinct Order Date with at least one Sales row surviving the applicable business filters. Several order lines or orders on the same date form one purchase day. A second order on the same day does not establish a previous purchase day.</p>
<p>For each visible purchase day, find the immediately preceding, strictly earlier purchase day for that customer. That preceding day can be outside the visible date selection.</p>
<p>Include the current purchase day’s Sales Amount when the gap is between 1 and 30 calendar days, inclusive. Exclude the first purchase day in the available history and any day whose preceding purchase day is more than 30 days earlier. Include all selected sales lines on a qualifying day, exactly once.</p>
<h2>Acceptance examples</h2>
<p>With purchase days January 1, January 20, and February 25, January 20 qualifies, and February 25 does not. Selecting only January 20 must still find January 1.</p>
<p>A gap of exactly 30 days qualifies; a gap of 31 days does not.</p>
<p>If the only preceding purchase within 30 days is outside a selected category or store, it does not qualify the current day under that selection.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0311-01-repeat-purchase-timeline.svg" width="800" /></p>
<p>When asked to create the measure, AI generates this code:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Repeat Purchase Sales =
SUMX (
    VALUES ( Customer&#x5B;CustomerKey] ),
    VAR HistoricalPurchaseDates =
        CALCULATETABLE ( VALUES ( Sales&#x5B;Order Date] ), REMOVEFILTERS ( &#039;Date&#039; ) )
    VAR VisiblePurchaseDates =
        CALCULATETABLE ( VALUES ( Sales&#x5B;Order Date] ) )
    RETURN
        SUMX (
            VisiblePurchaseDates,
            VAR PurchaseDate = Sales&#x5B;Order Date]
            VAR PreviousPurchaseDate =
                MAXX (
                    FILTER ( HistoricalPurchaseDates, Sales&#x5B;Order Date] &lt; PurchaseDate ),
                    Sales&#x5B;Order Date]
                )
            VAR GapDays = PurchaseDate - PreviousPurchaseDate
            RETURN
                IF (
                    NOT ISBLANK ( PreviousPurchaseDate ) &amp;&amp; GapDays &lt;= 30,
                    CALCULATE ( &#x5B;Sales Amount] )
                )
        )
)
</pre>
<p>This measure works fine; it satisfies the contract. However, to a seasoned DAX developer, a few details immediately jump out:</p>
<ul>
<li>There are as many as three levels of nested iterations: an outer SUMX, an inner SUMX inside the RETURN part, and an even deeper MAXX over a FILTER. This is potentially bad.</li>
<li>The outer iteration has the cardinality of <em>Customer</em>; the inner iteration has the cardinality of <em>Date</em>. Both cardinalities are large. Also, the MAXX iteration has the cardinality of <em>Date </em>as well, which is not small. Multiplying those cardinalities produces a large number of rows to evaluate.</li>
<li>CALCULATETABLE inside SUMX (see <em>VisiblePurchaseDates</em>) can generate large temporary variables, thus producing inefficient code.</li>
</ul>
<p>These are all signs of possible optimizations. The DAX engine will likely eliminate some iterations and replace them with table scans at a finer granularity; however, there is still room for improvement.</p>
<p>To challenge the AI, we first worked on the formula ourselves, creating our own optimized version:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Repeat Purchase Sales (Human) =
VAR MaxDelta = 30
VAR DateStart = MIN ( &#039;Date&#039;&#x5B;Date] )
VAR DateEnd = MAX ( &#039;Date&#039;&#x5B;Date] )
VAR CustomersAndDates =
    ADDCOLUMNS (
        CALCULATETABLE (
            SUMMARIZE ( Sales, Customer&#x5B;CustomerKey], Sales&#x5B;Order Date] ),
            REMOVEFILTERS ( &#039;Date&#039; ),
            &#039;Sales&#039;&#x5B;Order Date] &gt;= DateStart - MaxDelta &amp;&amp; &#039;Sales&#039;&#x5B;Order Date] &lt;= DateEnd
        ),
        &quot;@SalesAmount&quot;, &#x5B;Sales Amount]
    )
VAR AddDeltas =
    ADDCOLUMNS (
        CustomersAndDates,
        &quot;@Delta&quot;,
            Sales&#x5B;Order Date]
                - SELECTCOLUMNS (
                    OFFSET (
                        -1,
                        CustomersAndDates,
                        ORDERBY ( Sales&#x5B;Order Date] ),
                        PARTITIONBY ( Customer&#x5B;CustomerKey] )
                    ),
                    Sales&#x5B;Order Date]
                )
    )
VAR Result = 
    SUMX ( 
        FILTER ( 
            AddDeltas, 
            &#x5B;@Delta] &lt;= MaxDelta &amp;&amp; Sales&#x5B;Order Date] &gt;= DateStart 
        ), 
        &#x5B;@SalesAmount] 
    )
RETURN
    Result
</pre>
<p>Here is the rationale behind the changes:</p>
<ul>
<li>The formula first collects in <em>CustomersAndDates</em> the relevant pairs of customers and dates, along with the sales amount. The idea is to retrieve the sales amount during this scan to reduce the number of <em>Sales</em> scans. It looks promising, but it is not, as we will see later.</li>
<li>To reduce the size of the table, rather than scanning all dates, <em>CustomersAndDates</em> goes back no more than 30 days, because any transaction earlier than 30 days from the minimum is pointless for the algorithm.</li>
<li>We use the new OFFSET function to compute the previous order date, as OFFSET (being new) is more likely to be well-optimized.</li>
<li>The final FILTER is needed to avoid considering the additional earlier dates that are present in <em>AddDelta</em>, through <em>CustomersAndDates</em>.</li>
</ul>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0311-04-offset-previous-day-1.svg" width="800" /></p>
<p>To produce this optimized version, we did not check the formula engine, storage engine, or other details. The formula structure makes it clear that the code is heavily dependent on the formula engine; therefore, the only good option is to reduce the size of the temporary tables.</p>
<p>At the same time, we asked AI to produce an optimized version of the original formula. Here is the result:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Repeat Purchase Sales AI Independent = 
VAR FirstVisibleDate = MIN ( &#039;Date&#039;&#x5B;Date] )
VAR LastVisibleDate = MAX ( &#039;Date&#039;&#x5B;Date] )
RETURN
    SUMX (
        VALUES ( Customer&#x5B;CustomerKey] ),
        VAR HistoricalPurchaseDates =
            CALCULATETABLE (
                VALUES ( Sales&#x5B;Order Date] ),
                REMOVEFILTERS ( &#039;Date&#039; ),
                &#039;Date&#039;&#x5B;Date] &gt;= FirstVisibleDate - 30,
                &#039;Date&#039;&#x5B;Date] &lt; LastVisibleDate
            )
        VAR VisiblePurchaseDays =
            CALCULATETABLE (
                SUMMARIZECOLUMNS ( Sales&#x5B;Order Date], &quot;@SalesAmount&quot;, &#x5B;Sales Amount] )
            )
        VAR QualifyingPurchaseDays =
            FILTER (
                VisiblePurchaseDays,
                VAR PurchaseDate = Sales&#x5B;Order Date]
                RETURN
                    COUNTROWS (
                        FILTER (
                            HistoricalPurchaseDates,
                            Sales&#x5B;Order Date] &lt; PurchaseDate 
                                &amp;&amp; Sales&#x5B;Order Date] &gt;= PurchaseDate - 30
                        )
                    ) &gt; 0
            )
        RETURN
            SUMX ( QualifyingPurchaseDays, &#x5B;@SalesAmount] )
    )
</pre>
<p>There are some interesting details in the version created by AI:</p>
<ul>
<li>It used the same optimization we found, limiting the temporary <em>HistoricalPurchaseDates</em> table to only 30 days earlier. This is honestly unexpected; we did not think AI could uncover this detail.</li>
<li>It uses SUMMARIZECOLUMNS inside an iteration to create <em>VisiblePurchaseDays</em>. We would not use SUMMARIZECOLUMNS inside a row context, even with a previous context transition, because it is scary, to say the least: the interactions between the logic of SUMMARIZECOLUMNS and the row/filter context are very complex to manage.</li>
<li>It precomputes <em>Sales Amount </em>inside SUMMARIZECOLUMNS, using a technique similar to what we did.</li>
<li>It still maintains multiple iterations. The outer iteration is SUMX over the customers, the inner iteration is FILTER over <em>HistoricalPurchaseDates</em>. However, it reduced the number of nested iterations.</li>
</ul>
<p>During this optimization phase, the AI agent not only created a new version of the code but also generated an extensive set of queries to verify that the new measure is functionally equivalent to the old measure.</p>
<p>The query is too long to show here – again, see the download section. However, it is a gigantic set of subqueries like this:</p>
<pre class="brush: dax; highlight: [5,9]; notranslate">
    ROW (
        &quot;Test&quot;, &quot;01 First purchase day is blank&quot;,
        &quot;Expected&quot;, BLANK (),
        &quot;Baseline&quot;, CALCULATE ( 
            &#x5B;Repeat Purchase Sales Baseline],
            TREATAS ( { 245745 }, Customer&#x5B;CustomerKey] ),
            TREATAS ( { DATE ( 2016, 9, 7 ) }, &#039;Date&#039;&#x5B;Date] ) ),
        &quot;Candidate&quot;, CALCULATE ( 
            &#x5B;Repeat Purchase Sales Under Test],
            TREATAS ( { 245745 }, Customer&#x5B;CustomerKey] ),
            TREATAS ( { DATE ( 2016, 9, 7 ) }, &#039;Date&#039;&#x5B;Date] ) )
    )
</pre>
<p>It runs the two measures under well-known test cases that verify edge-case scenarios, then checks that the results match.</p>
<p>Let us be very honest. We have optimized thousands of DAX measures in the last 15 years. We have never prepared such an extensive set of tests, even though we knew we should have. We just never had the time and the patience to build the test sets. The fact that AI does not get bored and is also very precise when writing code makes it worth integrating into the optimization process.</p>
<p>Next, it prepared a set of queries to test the performance of the measures. Again, it identified a few test scenarios:</p>
<ul>
<li>One full year</li>
<li>Grouping by month in a full year</li>
<li>Grouping by month and country in a full year</li>
<li>Grouping by month and category in a full year</li>
<li>One large, big total with no grouping</li>
</ul>
<p>The selection of the test set of performance queries is smart. It performs grouping by different columns in different tables, using time as the primary grouping column. It accurately checks how different granularities affect the measured metric. Very well done.</p>
<p>Here are the results – in milliseconds – of the three versions:</p>
<table>
<tbody>
<tr>
<td><strong>Test query</strong></td>
<td><strong>Baseline</strong></td>
<td><strong>Human version</strong></td>
<td><strong>Independent AI</strong></td>
</tr>
<tr>
<td>10 — 2025 total</td>
<td>1,244</td>
<td>354</td>
<td>340</td>
</tr>
<tr>
<td>11 — By month</td>
<td>998</td>
<td>866</td>
<td>705</td>
</tr>
<tr>
<td>12 — Month × country</td>
<td>1,166</td>
<td>891</td>
<td>715</td>
</tr>
<tr>
<td>13 — Month × category</td>
<td>2,710</td>
<td>1,678</td>
<td>1,345</td>
</tr>
<tr>
<td>14 — All-history total</td>
<td>4,396</td>
<td>2,594</td>
<td>3,910</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>As you can see, there is no clear winner. The AI-generated version is better in some scenarios and worse in others. With different data distributions, the results would be different again. However, it is fair to say the AI-optimized version is not bad at all. This is not the place for a deep dive, but the biggest gain is the shift to 30-day earlier dates, which both optimizations achieve.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0311-02-thirty-day-lookback.svg" width="800" /></p>
<p>The story could end here, with a substantial draw between SQLBI and AI. However, as we said in the introduction, this was never a contest. This study aims to identify the best way to use AI in the optimization process. Therefore, we asked AI to further optimize our version. The result is a small change that makes all the difference:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Repeat Purchase Sales AI =
VAR DateStart = MIN ( &#039;Date&#039;&#x5B;Date] )
VAR DateEnd = MAX ( &#039;Date&#039;&#x5B;Date] )
VAR PurchaseDays =
    CALCULATETABLE (
        SUMMARIZE ( Sales, Sales&#x5B;CustomerKey], Sales&#x5B;Order Date] ),
        REMOVEFILTERS ( &#039;Date&#039; ),
        Sales&#x5B;Order Date] &gt;= DateStart - 30,
        Sales&#x5B;Order Date] &lt;= DateEnd
    )
VAR QualifiedDays =
    FILTER (
        PurchaseDays,
        VAR PurchaseDate = Sales&#x5B;Order Date]
        VAR PreviousPurchaseDate =
            MAXX (
                OFFSET (
                    -1,
                    PurchaseDays,
                    ORDERBY ( Sales&#x5B;Order Date], ASC ),
                    PARTITIONBY ( Sales&#x5B;CustomerKey] )
                ),
                Sales&#x5B;Order Date]
            )
        RETURN
            PurchaseDate &gt;= DateStart
                &amp;&amp; NOT ISBLANK ( PreviousPurchaseDate )
                &amp;&amp; PurchaseDate - PreviousPurchaseDate &lt;= 30
    )
RETURN
    CALCULATE (
        &#x5B;Sales Amount],
        KEEPFILTERS ( QualifiedDays )
    )
</pre>
<p>As you can see, the AI agent did not compute the sales amount in the initial SUMMARIZE. Instead it scanned the <em>Sales</em> table again at the end, using the <em>QualifiedDays</em> variable as a filter in CALCULATE. The remaining part of the code is basically identical to mine.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0311-03-nested-iterations.svg" width="800" /></p>
<p>The results, in milliseconds, are very interesting:</p>
<table>
<tbody>
<tr>
<td width="174"><strong>Test query</strong></td>
<td width="63"><strong>Baseline</strong></td>
<td><strong>Human version</strong></td>
<td style="background-color: #ebe8fa"><strong>AI refinement</strong></td>
<td><strong>Independent AI</strong></td>
</tr>
<tr>
<td width="174">10 — 2025 total</td>
<td width="63">1,244</td>
<td>354</td>
<td style="background-color: #ebe8fa">236</td>
<td>340</td>
</tr>
<tr>
<td width="174">11 — By month</td>
<td width="63">998</td>
<td>866</td>
<td style="background-color: #ebe8fa">775</td>
<td>705</td>
</tr>
<tr>
<td width="174">12 — Month × country</td>
<td width="63">1,166</td>
<td>891</td>
<td style="background-color: #ebe8fa">730</td>
<td>715</td>
</tr>
<tr>
<td width="174">13 — Month × category</td>
<td width="63">2,710</td>
<td>1,678</td>
<td style="background-color: #ebe8fa">1,299</td>
<td>1,345</td>
</tr>
<tr>
<td width="174">14 — All-history total</td>
<td width="63">4,396</td>
<td>2,594</td>
<td style="background-color: #ebe8fa">1,538</td>
<td>3,910</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0311-06-query-duration-chart.svg" width="800" /></p>
<p>Overall, if this were a competition, our measure, further optimized by the agent, would win. Since this is not a competition, it just shows a lot about how to optimize code with AI.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0311-05-human-ai-workflow.svg" width="800" /></p>
<p>AI is not a replacement for humans. Its results are good, but not exceptional. The same goes for humans. If we had been left to work on this more deeply, we would probably have tested the AI-refined version and found a better one. However, AI found the best version much more quickly than we ever could. Moreover, an extensive set of queries supported the findings by validating that all tested measures use the same logic, and the tests used multiple, well-crafted queries that verified different query structures.</p>
<p>We are only scratching the surface of what AI-centered development can do; using AI in the optimization process is definitely valuable.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/optimizing-dax-with-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
	</item>
		<item>
		<title>DAX with AI: Scenarios is now available</title>
		<link>https://www.sqlbi.com/blog/marco/2026/11/02/dax-with-ai-scenarios-is-now-available/</link>
					<comments>https://www.sqlbi.com/blog/marco/2026/11/02/dax-with-ai-scenarios-is-now-available/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Mon, 02 Nov 2026 09:00:25 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Video course]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=blogpost&#038;p=908113</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-scenarios-email.png" class="webfeedsFeaturedVisual" /></figure>This post describes DAX with AI: Scenarios, our new video course on using AI for complex business requirements in DAX. DISCLAIMER: I drafted this post with the help of AI, starting from my notes and the outlines of the course&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-scenarios-email.png" class="webfeedsFeaturedVisual" /></figure><p>This post describes DAX with AI: Scenarios, our new video course on using AI for complex business requirements in DAX.<br />
<span id="more-908113"></span></p>
<p><em>DISCLAIMER: I drafted this post with the help of AI, starting from my notes and the outlines of the course modules. I manually reviewed and edited the entire post.</em></p>
<p><a href="https://www.sqlbi.com/p/dax-with-ai-scenarios-video-course/">DAX with AI: Scenarios</a> is complete and available as of today, November 2, 2026: four weeks earlier than planned! When we launched the course in September, we committed to releasing it by November 30, 2026. If you've already enrolled, the new modules are available in the same course.</p>
<p>I announced this course in September, together with two other courses, in <a href="https://www.sqlbi.com/blog/marco/2026/09/22/where-we-stand-on-ai-and-dax-in-2026/">Where we stand on AI and DAX in 2026</a>. This post focuses on the new course only.</p>
<h2>Three Video Courses about using AI to write DAX</h2>
<p>DAX with AI: Scenarios completes the three courses we created for different steps in using <a href="https://www.sqlbi.com/ai/">AI to write DAX</a>:</p>
<ul>
<li><a href="https://www.sqlbi.com/p/ai-for-power-bi-intro-video-course/"><strong>AI for Power BI: Intro</strong><img decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/ai-for-powerbi-intro-email.png" alt="AI for Power BI: Intro (logo)" width="100" /></a> is a free course that explains the basics of AI in Power BI. It is not about Copilot: it is about using agents, skills, plugins, and MCP (Model Context Protocol) servers to manipulate Power BI models and reports.</li>
<li><a href="https://www.sqlbi.com/p/dax-with-ai-essentials-video-course/"><strong>DAX with AI: Essentials</strong><img decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-essentials.png" alt="DAX with AI: Essentials (logo)" width="100" /></a> teaches how to read the DAX code generated by AI tools. If you already know DAX, here you learn how to write correct prompts and how to use the agents to write measures. If you know the AI tools but you are new to DAX, you learn how to read DAX even if you cannot write it.</li>
<li><a href="https://www.sqlbi.com/p/dax-with-ai-scenarios-video-course/"><strong>DAX with AI: Scenarios</strong><img decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-scenarios.png" alt="DAX with AI: Scenarios (logo)" width="100" /></a> deals with complex scenarios where your work is mainly to control the direction of the development. This includes writing DAX code and modifying the model so that it produces the correct result for the business problem described.</li>
</ul>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-three-courses.svg" width="800" /></p>
<p>These courses are for those who are new to DAX or who aren't regularly using AI agents to write DAX. We focus on how you write the request, and we show how to reason about the problem, give instructions, and check the result. We do not teach AI tools, because they change so often that a course about the actual tools would become obsolete before it is even published. It does not matter whether you use Visual Studio Code, Claude, Codex, or other tools: you can find <a href="https://docs.sqlbi.com/ai/tools/">installation instructions on separate pages</a> that we keep up to date.</p>
<h2>Concepts and scenarios</h2>
<p>The course is organized in two tracks: Common Concepts and Scenarios.</p>
<p>A <strong>concept</strong> lesson explains, with practical demos, a design pattern you can use in several scenarios. For example, the lesson on grain uses a model of lemonade recipes, where sugar and lemon juice depend on the water in each recipe. If you apply the recipe rates after adding up the water, the quantities are wrong. The small model makes this error visible without the noise of a large model.</p>
<p>Three concept lessons cover topics we also described in recent articles: <a href="https://www.sqlbi.com/articles/understanding-dax-contracts-when-using-ai/">Understanding DAX contracts when using AI</a>, <a href="https://www.sqlbi.com/articles/writing-dax-at-the-correct-granularity/">Writing DAX at the correct granularity</a>, and <a href="https://www.sqlbi.com/articles/the-hidden-complexity-of-a-daily-average-in-dax/">The hidden complexity of a daily average in DAX</a>.</p>
<p>The same concept comes back in different scenarios with a different business meaning. This is the reason why the course separates concepts from scenarios. Each concept is explained once in its own dedicated lesson, and each scenario can be followed without repeating those explanations.</p>
<h2>Scenarios’ prerequisites</h2>
<p>Every scenario starts with a short introduction that presents the learning targets and the concepts needed: new concepts, and concepts already viewed. New concepts are required for the first time in the course sequence, and you should study them (or make sure you already know them) before the scenario. Already viewed concepts are lessons introduced in previous scenarios.</p>
<p>If you follow the course in order, this introduction tells you what to watch next. For example, the comparable-store scenario lists the lesson on virtual tables and lineage as new, because no earlier scenario requires it. It also lists five other lessons as already viewed.</p>
<p>If you start from a specific scenario, the two lists together are your prerequisites. You may already know some of these concepts: you'll want to either skip them, or watch them as a review. When a concept is new to you, the corresponding lesson is there.</p>
<p>This lets you start with the scenario you need in the short term. For example, imagine you must compare actuals with an annual budget next week. You can start from the budget and forecast scenario after checking its six concept lessons, without watching the previous five scenarios.</p>
<p>The concepts are few, but every scenario uses most of them. The first five lessons, from calculation contracts to time and snapshots, are required by all ten scenarios. If you plan to follow more than one scenario, my suggestion is to watch those five lessons first. The module table below shows the concepts required by each scenario.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-scenarios-concepts.svg" width="800" /></p>
<h2>Every scenario follows the same method</h2>
<p>All the scenarios use the Contoso model, extended with tables for support tickets, inventory, budget and forecast, operating costs, accounting, and workforce. The data is synthetic but consistent across tables. For example, the monthly profit and loss snapshots reconcile with the accounting journal within one cent for every account, store, and month.</p>
<p>In every demo, the AI agent works on the semantic model through an MCP server. It inspects the metadata, runs DAX queries, and creates measures, functions, calculated tables, and calculation groups. Each module includes the demo files and the prompts used in the videos.</p>
<p>After the introduction, each scenario submits the request that a business user could write. For example, the support scenario starts by asking AI for ticket volume, resolution time, SLA compliance, and activity by channel and store. The measures may look correct and still count interactions as tickets, or silently use the wrong date or store.</p>
<p>Then we delete those measures and ask AI which questions can change the result. Our answers become a calculation contract: a short list of rules about the counted entity, the population, the dates, the filters, and the totals. We save the contract and extend it before each new calculation, instead of agreeing on every detail at the beginning.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-scenario-method.svg" width="800" /></p>
<p>Each scenario also includes a mistake that AI is likely to make on that requirement. For example, in the inventory scenario, AI may use one global snapshot date for all the products and stores. However, what happens on April 30 if the latest snapshot falls on six different dates, depending on the product and the store? When AI makes a mistake, we show how the contract and the validation expose it. When AI writes correct code, we explain why the code works, instead of forcing an error.</p>
<p>Validation uses evidence that does not depend on the measure being tested. For example, the last scenario changes two measures in an existing model. Before the change, we save a baseline query with the results of all 45 measures. After the change, we check that only the six measures affected by the two corrections return different results.</p>
<h2>Concepts and scenarios included</h2>
<p>The following tables list all the modules, with the concept lessons required by each scenario.</p>
<h3>Common Concepts</h3>
<table>
<tbody>
<tr>
<td><strong>Lesson</strong></td>
<td><strong>Topic</strong></td>
<td><strong>Duration (min)</strong></td>
</tr>
<tr>
<td>C1 – Calculation Contracts and Strength of Claims</td>
<td>What "average sale" means: a short contract before the code, because correct DAX can answer the wrong question</td>
<td>24</td>
</tr>
<tr>
<td>C2 – Grain, Iteration Grain, Additivity, and Totals</td>
<td>Source, rule, iteration, and output grain, with a small lemonade model where rates applied after aggregation give wrong quantities</td>
<td>22</td>
</tr>
<tr>
<td>C3 – Populations, Denominators, and Validation</td>
<td>Which days and products belong in an average: blank versus zero, coverage boundaries, and benchmarks with ALL and ALLSELECTED</td>
<td>33</td>
</tr>
<tr>
<td>C4 – Filter Paths and Relationship Semantics</td>
<td>Sales by delivery date with USERELATIONSHIP, TREATAS, and CROSSFILTER, and an annual budget filtered by month but not allocated</td>
<td>27</td>
</tr>
<tr>
<td>C5 – Time, Events, States, and Snapshots</td>
<td>Events, intervals, states, and snapshots in a ticket backlog, and why daily states cannot be added over time</td>
<td>24</td>
</tr>
<tr>
<td>C6 – Reusable DAX: Measures, Functions, and Calculation Groups</td>
<td>One positive-sales rule written as measures, then as a user-defined function, then as a calculation group</td>
<td>18</td>
</tr>
<tr>
<td>C7 – Virtual Tables, Lineage, and Set-Based DAX</td>
<td>Customers in the countries of the selected stores with TREATAS, INTERSECT, and EXCEPT, counting each customer once</td>
<td>17</td>
</tr>
</tbody>
</table>
<h3>Scenarios</h3>
<table>
<tbody>
<tr>
<td><strong>Scenario</strong></td>
<td><strong>Topic</strong></td>
<td><strong>Concepts</strong></td>
<td><strong>Duration (min)</strong></td>
</tr>
<tr>
<td>1 – Currency Conversion with Historical and Current Rates</td>
<td>USD sales converted at the order-date rate or at the current rate, then a reusable function and the limits of its reuse</td>
<td>C1–C6</td>
<td>67</td>
</tr>
<tr>
<td>2 – Comparable-Store Sales</td>
<td>Three definitions of comparable store (sales activity, lifecycle dates, operational status) applied as one cohort to both periods</td>
<td>C1–C5, C7</td>
<td>114</td>
</tr>
<tr>
<td>3 – Yearly Product Status Transitions</td>
<td>One stored status per product and year, a transition matrix, and its logic reused through a function and a calculation group</td>
<td>C1–C7</td>
<td>61</td>
</tr>
<tr>
<td>4 – Support Ticket Resolution and Interaction Journeys</td>
<td>Tickets versus interactions, SLA compliance, historical backlog, first and final channel, and Store and Date roles selected with calculation groups</td>
<td>C1–C7</td>
<td>107</td>
</tr>
<tr>
<td>5 – Inventory Availability from Movements, Sparse Snapshots, and Reservations</td>
<td>End-of-day stock from sparse snapshots and signed movements, reservations as effective intervals, and three stock algorithms compared</td>
<td>C1–C7</td>
<td>125</td>
</tr>
<tr>
<td>6 – Budget, Forecast, and Actuals at Incompatible Grains</td>
<td>Annual budget and versioned monthly forecast compared with actuals, allocation with stored weights, and actuals continued by the latest forecast</td>
<td>C1–C5, C7</td>
<td>98</td>
</tr>
<tr>
<td>7 – Shared-Cost Allocation and Profitability</td>
<td>Store operating costs allocated to products and customers with sales, purchase, and inventory drivers, visible residuals, and materialized weights</td>
<td>C1–C7</td>
<td>109</td>
</tr>
<tr>
<td>8 – Financial Statements with Ragged Accounts</td>
<td>Profit and loss and balance sheet over a ragged account hierarchy, with consolidation eliminations, closing balances, and partial periods</td>
<td>C1–C5, C7</td>
<td>134</td>
</tr>
<tr>
<td>9 – Workforce Analytics</td>
<td>Headcount, movements, and capacity from an employee-day fact, then as-of salaries in one currency compared with role peers</td>
<td>C1–C7</td>
<td>110</td>
</tr>
<tr>
<td>10 – Adopting an Existing Model with AI</td>
<td>A disputed report on an existing model: recover its contracts, correct two measures, and validate what changed and what did not</td>
<td>C1–C6</td>
<td>61</td>
</tr>
</tbody>
</table>
<h2>Conclusions</h2>
<p>DAX with AI: Scenarios is a library of ten business scenarios and seven concept lessons. It is the third of the three video courses we had announced in September: the first introduces the tools, the second teaches how to read the DAX written by AI, and the third applies both to complex requirements.</p>
<p>You do not need to watch this course from beginning to end. Choose the scenario closest to your next project, check the concepts listed in its introduction, and watch only the lessons you need.</p>
<p>In every scenario, the rule is the same: agree on the contract before asking AI to generate the code, then validate the result.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/blog/marco/2026/11/02/dax-with-ai-scenarios-is-now-available/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DAX LLM Benchmark v2.0 Trailer</title>
		<link>https://www.sqlbi.com/tv/dax-llm-benchmark-v2-0-trailer/</link>
					<comments>https://www.sqlbi.com/tv/dax-llm-benchmark-v2-0-trailer/#respond</comments>
		
		<dc:creator><![CDATA[SQLBI]]></dc:creator>
		<pubDate>Tue, 27 Oct 2026 11:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[AI]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=907658</guid>

					<description><![CDATA[<figure><img src="https://i3.ytimg.com/vi/dKWCTUTeG9U/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>Which LLMs are ready to write DAX? Check it out at https://www.daxbench.com/]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i3.ytimg.com/vi/dKWCTUTeG9U/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>Which LLMs are ready to write DAX?<br />
Check it out at https://www.daxbench.com/</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/dax-llm-benchmark-v2-0-trailer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DAX LLM Benchmark v2</title>
		<link>https://www.sqlbi.com/blog/marco/2026/10/27/dax-llm-benchmark-v2/</link>
					<comments>https://www.sqlbi.com/blog/marco/2026/10/27/dax-llm-benchmark-v2/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Tue, 27 Oct 2026 10:45:53 +0000</pubDate>
				<guid isPermaLink="false">https://www.sqlbi.com/?post_type=blogpost&#038;p=907288</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/daxbench-v2-03.png" class="webfeedsFeaturedVisual" /></figure>The DAX LLM Benchmark v2 shows that the latest frontier models write DAX very well, and that the model generation matters more than the vendor. This post describes how we built the benchmark, how we read its results, and what&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/daxbench-v2-03.png" class="webfeedsFeaturedVisual" /></figure><p><em>The DAX LLM Benchmark v2 shows that the latest frontier models write DAX very well, and that the model generation matters more than the vendor. This post describes how we built the benchmark, how we read its results, and what I think it means for DAX.</em><br />
<span id="more-907288"></span></p>
<p>The second version of the <a href="https://www.daxbench.com/">DAX LLM Benchmark</a> is online at <a href="https://www.daxbench.com">www.daxbench.com</a>. Its results show that the latest generations of frontier models write DAX very well, and they differ significantly from older generations, even those just a few months old. Open-source models still lag behind, but they follow the same trend.</p>
<p>&nbsp;</p>
<blockquote>
<table style="width: 100%; border: none !important; border-collapse: collapse; box-shadow: none;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 100%; border: none !important; padding: 0 0px 0 0; vertical-align: middle;">On Nov. 4, 15:00 UTC we explained the making of DAX LLM Benchmark v2 and answered many questions; the <a href="https://youtu.be/WzWYiTaj8mM"><strong>full recording is available on YouTube</strong></a>.</td>
</tr>
<tr>
<td style="width: 60%; border: none !important; padding: 0; vertical-align: middle;"><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxllmbenchmarkv2-live.jpg" alt="Inside DAXBench v2: Results and Your Questions - recorded on Nov. 4, 15:00 UTC." /></td>
</tr>
</tbody>
</table>
</blockquote>
<h2>How v2 started</h2>
<p>Over the last few months, I worked with <a href="https://www.linkedin.com/in/maxanatsko">Maxim Anatsko</a> to create a second, more advanced version of the DAX LLM Benchmark. Maxim released the first version in December 2025. When I saw the first version, I was impressed. It was the first time I saw a complete, reproducible, relatively broad set of tests to evaluate the ability of an LLM to “understand” and write DAX expressions correctly. I had been thinking for a while about how to implement tests to “measure” an LLM’s ability to write DAX; Maxim’s work seemed very close to what I had in mind.</p>
<p>I quickly contacted Maxim to better understand how it worked and which plans he had moving forward. It did not take long to conclude that working together would benefit both the Power BI community and us. This past summer, we improved the benchmark engine and created tests that covered many more real-world examples of varying complexity.</p>
<p>I do not think that the tests we created are perfect. Like a certification exam, tests can be valid up to a certain point. The usefulness of a model in the real world matters more. A perfect model could fail to handle a specific business requirement, and a below-average model could be more than enough for several users. We understand that, and I want to be the first to write a disclaimer: you should not judge a model just by its benchmarks; your personal experience matters more than any benchmark. However, this new benchmark gives us a lot of information.</p>
<h2>How the benchmark works</h2>
<p>We have a <a href="https://www.daxbench.com/methodology">page describing the methodology</a> used in the benchmark. Every test is a single-shot request with the default reasoning level provided for each given model. The model can reason, but we intentionally disabled the ability for the agent to iterate over solutions and retest them. Moreover, we do not provide any skills to the agents. These decisions make the benchmark far from the real world. However, this is the only way to evaluate the model’s “native” skill. We assume that a better “native” competence level generally corresponds to a better outcome of the final result. In short, we wanted a tool to help us choose a model and assess whether other models surpass our current choice in performance or cost.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxbench-v2-01.png" width="800" /></p>
<p>Usually, a test requires writing one or more DAX formulas in an existing model where other DAX measures exist. In some cases, we need to fix an existing DAX measure to meet updated requirements. We also test DAX queries, calculated tables, calculated columns, and user-defined functions (UDF). Most of the semantic models are based on variations of the Contoso model we often use in SQLBI content.</p>
<p>We test the DAX code, not the semantic model. We know that a more comprehensive test should also include the data modeling side. We do not completely ignore the data model, because a few tests require understanding a non-trivial semantic model. However, we did not set data modeling as a specific goal, because older LLMs already struggle with relatively complex formulas and scenarios.</p>
<p>Every test runs on a semantic model loaded for that test. The response of the LLM alters the semantic model; the benchmark engine then runs a test query to validate the changes the LLM applied. If the response produces the expected results, we do a deeper analysis to verify best practices and the “distance” from the reference solution. We tried to avoid giving low scores to correct solutions just because the generated code was far from the reference one.</p>
<p>We compare the solution of each LLM run with the reviewed reference solution, and we compare its results with the expected ones. The final score combines evaluation metrics that measure the number of tasks completed successfully, output accuracy, and syntax correctness. However, we do not provide a score to a task that does not complete correctly, even though it is syntactically correct and well-formatted.</p>
<h2>What the results show</h2>
<p>At the time of writing (October 18, 2026), several models from different vendors share very similar scores. Small differences in the final score are not very important because they come from minor variations that could be irrelevant in daily use. More helpful is how close several LLMs are to a perfect score, which suggests that choosing a specific LLM vendor may matter less than choosing the model generation, regardless of vendor.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxbench-v2-02.png" width="800" /></p>
<p>Another important outcome is the improvement curve across model generations. Because these tests do not rely on LLM memory or sessions, the only reason we see improvement is that the models have evolved.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxbench-v2-03.png" width="800" /></p>
<p>Costs differ significantly, and we compute them using API pricing while ignoring subscription savings. For certain applications, the API cost could be minimal, so the choice between models could depend on quality alone; but with higher consumption and over the long run, you probably want to keep costs under control. The <strong>Value Analysis</strong> compares the models from that perspective.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxbench-v2-04.png" width="800" /></p>
<h2>What this means for DAX</h2>
<p>If you had asked me one year ago (October 2025), I would never have thought that the improvement in DAX writing we have seen in one year would be possible. I was using (and still use) LLM tools for many other tasks, but the improvements in DAX did not keep pace with the speed of improvements in coding until then. This changed with the frontier models released starting in April 2026. Six models from three different vendors, released in August and September 2026, score between 90% and 96% on our new benchmark. I almost feel the need to create version 2.1 or 3.0 of the benchmark: every task was solved by at least one LLM. We will probably find where the bar is. However, it is already above the level that helps many users.</p>
<p>That is why, in September 2026, <a href="https://www.sqlbi.com/blog/marco/2026/09/22/where-we-stand-on-ai-and-dax-in-2026/">I wrote that using AI to write DAX has started to be effective</a>: I was not confident in a similar statement six months earlier, but now an agent can save time writing DAX.</p>
<p>I expect the question: "If an LLM writes DAX, is it still worth learning DAX?" The short answer: yes, and not only because I love the language and part of my job is teaching it. At least being able to read DAX code gives you an intermediate view of how business rules are implemented. Descriptions of the specification in English (which we call <a href="https://www.sqlbi.com/articles/understanding-dax-contracts-when-using-ai/">contracts</a>) can still be ambiguous about how a measure is interpreted when it involves unrelated attributes. DAX provides a clear and deterministic explanation of the algorithm. It could be wrong and must be fixed, but different clients will always get the same numbers for the same report. Being able to read the DAX code an LLM generates lets you validate the business rules the development team implemented.</p>
<p>LLMs can also create and automate validation tests, but it is harder to build a set of measures that will last without knowing the master plan in detail. That is why implementing a business rule in DAX also documents the intended behavior better.</p>
<p>Another note: complexity is no longer a limit. For years, I heard people say that DAX complexity limited its adoption. That limit is gone, and, in general, language complexity limits are gone. DAX was created because MDX was too hard, and it is simpler at the cost of a few MDX features, such as recursion and hierarchies. When an LLM writes the code, a language can be more complex if it is more powerful, because people no longer write every expression by hand. Compatibility with legacy reports and models remains a constraint, but migration costs could be lowered. This makes so many evolutions possible that it is extremely hard to predict what could happen in two to three years.</p>
<h2>Conclusions</h2>
<p>The latest generation of frontier models writes DAX well enough to save time, and model generation matters more than the vendor. At the time of writing, six models from three vendors score between 90% and 96% on the DAX LLM Benchmark v2.</p>
<p>One final recommendation: use the benchmark to choose a model generation and to keep costs under control, but validate the results with your own tests on your own semantic models.</p>
<p>Enjoy the ride!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/blog/marco/2026/10/27/dax-llm-benchmark-v2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Install DAX libraries into Power BI Desktop by asking your AI assistant</title>
		<link>https://www.sqlbi.com/blog/marco/2026/10/22/install-dax-libraries-into-power-bi-desktop-by-asking-your-ai-assistant/</link>
					<comments>https://www.sqlbi.com/blog/marco/2026/10/22/install-dax-libraries-into-power-bi-desktop-by-asking-your-ai-assistant/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Thu, 22 Oct 2026 07:30:36 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=blogpost&#038;p=907384</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/daxlib-2.png" class="webfeedsFeaturedVisual" /></figure>At the end of 2025, we launched DAX Lib, a public repository of DAX user-defined functions. So far, importing a DAX library has required a few manual steps, like clicking Add to Power BI on daxlib.org and then copying and&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/daxlib-2.png" class="webfeedsFeaturedVisual" /></figure><p><img decoding="async" class="nozoom" style="float: right;margin: 0 0 10px 10px;border: none !important" src="https://www.sqlbi.com/wp-content/uploads/daxlib-1.png" alt="" width="238" height="198" />At the end of 2025, we launched <a href="https://daxlib.org/">DAX Lib</a>, a public repository of DAX user-defined functions. So far, importing a DAX library has required a few manual steps, like clicking Add to Power BI on daxlib.org and then copying and pasting the DAX code into the TMDL View of your model, or using the dedicated tool in Tabular Editor 3. Both work well, but if you already use an AI assistant next to Power BI Desktop, we can now delegate this task to it. The DAX Lib MCP server version 0.1.0 is available now.</p>
<h2>MCP server</h2>
<p>The DAX Lib MCP server connects your assistant to the DAX Lib catalog and to the Power BI Desktop models on your computer. It should work with any MCP client that supports local (stdio) servers, including Claude, Codex, GitHub Copilot in VS Code, Grok Code, Cursor, and many others. If it does not work for you, please <a href="https://github.com/daxlib/daxlib-mcp/issues">let us know</a>.</p>
<h2>What you can do with it</h2>
<p>You can make requests like these to your AI assistant:</p>
<ul>
<li>search DAX Lib for packages ("Search DAX Lib for packages that generate SVG images");</li>
<li>look at the details, the versions, and the README of a package ("Show the README of DaxLib.SVG");</li>
<li>list the Power BI Desktop models open on your machine;</li>
<li>install the functions of a package into a local model ("Install DaxLib.SVG into the Sales Report model").</li>
</ul>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxlib-mcp-01.png" width="800" /><br />
The MCP server downloads the package and writes the functions into the model directly, so you get the original code (including format and comments) and not a version retyped by a language model.</p>
<p>The installation adds the user-defined functions of the package to the semantic model. If a function with the same name already exists, it is replaced, without changing anything else in the model. The MCP server does not save your file after you import a package; save it in Power BI Desktop to keep the changes.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxlib-mcp-02.png" width="800" /></p>
<h2>You stay in control</h2>
<p>You choose the package, the version, and the target model. The assistant follows your instructions and doesn’t choose a package for you. The install tool is marked as a tool that changes data, so most MCP clients ask for your approval before they run it. Read the request before you approve it.</p>
<p>About privacy: the MCP server has no telemetry and does not collect usage data. It only invokes the DAX Lib API to search the catalog and to download package details, READMEs, and packages. The server is open source under the MIT license, so you can verify all these statements in the code on GitHub: <a href="https://github.com/daxlib/daxlib-mcp">daxlib/daxlib-mcp</a>.</p>
<h2>Limits you should know</h2>
<p>The DAX Lib MCP server has a few limits:</p>
<ul>
<li>It runs on Windows x64 only. No macOS plans at this time; if you need it, open a GitHub issue.</li>
<li>It installs only into models open in Power BI Desktop on the same computer.</li>
<li>The model needs compatibility level 1702 or higher, required for user-defined functions. The DAX Lib MCP server doesn't change it for you, but the <a href="https://learn.microsoft.com/en-us/power-bi/developer/mcp/power-bi-authoring-mcp">Power BI Authoring MCP server</a> (if installed) can raise it.</li>
<li>It does not remove or update existing functions. To update a package, just install the new version.</li>
<li>If you do not specify a version of a package, you get the latest published one, which can be a prerelease.</li>
</ul>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/daxlib-mcp-03.png" width="800" /></p>
<h2>How to start</h2>
<p>You need Windows x64, Node.js 18 or later, and an MCP client. Follow the <a href="https://docs.daxlib.org/user-guide/mcp/install">installation instructions</a> and start looking for function libraries that can help your models and your reports.</p>
<p>We suggest using the Power BI Authoring MCP server to move from "is there a library for this?" to "write the measure" in the same conversation by using both MCP servers.</p>
<p>DAX Lib is a community project, and SQLBI supports it by developing and maintaining its infrastructure and tools. The MCP server is one more of those tools.</p>
<p>There are no more excuses to include user-defined functions in your semantic models: try DAX Lib with your assistant and <a href="https://github.com/daxlib/daxlib-mcp/issues">write your feedback</a> if you have suggestions or find bugs.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/blog/marco/2026/10/22/install-dax-libraries-into-power-bi-desktop-by-asking-your-ai-assistant/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Continuous axis for any Date table in Power BI</title>
		<link>https://www.sqlbi.com/tv/continuous-axis-for-any-date-table-in-power-bi/</link>
					<comments>https://www.sqlbi.com/tv/continuous-axis-for-any-date-table-in-power-bi/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Tue, 20 Oct 2026 10:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=906780</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/W_mQVl5KQoM/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>How to get a continuous X-axis at the month level in Power BI with any Date table, like the one we get using the auto date/time feature.]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/W_mQVl5KQoM/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>How to get a continuous X-axis at the month level in Power BI with any Date table, like the one we get using the auto date/time feature.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/continuous-axis-for-any-date-table-in-power-bi/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Continuous axis for any Date table in Power BI</title>
		<link>https://www.sqlbi.com/articles/continuous-axis-for-any-date-table-in-power-bi/</link>
					<comments>https://www.sqlbi.com/articles/continuous-axis-for-any-date-table-in-power-bi/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Mon, 19 Oct 2026 20:00:42 +0000</pubDate>
				<category><![CDATA[Power BI]]></category>
		<category><![CDATA[semantic model]]></category>
		<category><![CDATA[Tabular]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=906737</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0310-11.png" class="webfeedsFeaturedVisual" /></figure>Power BI enables the continuous X-axis on the auto date/time hierarchy even at the month level. We can get the same behavior on any Date table by setting the right metadata in TMDL. In a previous article, Creating a simpler&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0310-11.png" class="webfeedsFeaturedVisual" /></figure><p>Power BI enables the continuous X-axis on the auto date/time hierarchy even at the month level. We can get the same behavior on any Date table by setting the right metadata in TMDL.<br />
<span id="more-906737"></span></p>
<p>In a previous article, <a href="https://www.sqlbi.com/articles/creating-a-simpler-and-chart-friendly-date-table-in-power-bi/">Creating a simpler and chart-friendly Date table in Power BI</a>, we showed you how to create a <em>Date</em> table you can use in a line chart with a continuous X-axis instead of a categorical one, even when the granularity is the month rather than the day. That technique stores every level as a DateTime column and relies on custom format strings to display the month name.</p>
<p>The auto date/time feature in Power BI provides the same user experience using a different technique. Its hidden date table uses text columns for quarters and months, sorted by a numeric column. However, the line chart still offers a continuous X-axis when you drill down to the month level. We keep saying that auto date/time is not a best practice, but this behavior is useful. Can we obtain it with our own <em>Date</em> table? Yes, we can.</p>
<p>If you have a <em>Date</em> table in your model (as you should!), this article explains how to enable the continuous X-axis in your report when the user groups dates by year, quarter, month, or week.</p>
<h2>How auto date/time navigation works</h2>
<p>The table created by auto date/time exposes a single hierarchy with four levels: <em>Year</em>, <em>Quarter</em>, <em>Month</em>, and <em>Day</em>. You cannot customize these levels, and the user does not see any other column in that table. Internally, <em>Quarter</em> and <em>Month</em> are text columns sorted by a hidden numeric column.</p>
<p>If we place the <em>Date</em> hierarchy from the auto date/time column on the X-axis of a line chart and drill down to the <em>Month</em> level, the X-axis type is still Continuous, whereas when we use the <em>Year Month</em> column of the classic <em>Date</em> table, the X-axis is Categorical.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-01.png" width="800" /><br />
The Type property of the line chart is usually available only when you can switch between Ordinal and Categorical, as in the auto date/time example. However, it is hidden when Power BI forces the X-axis to Categorical, as in the previous line chart for the classic <em>Date</em> table.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-02.png" width="200" /><br />
At first glance, this looks like an exception that Power BI makes for its own tables. But in reality, the line chart offers the continuous axis because the hidden table carries specific metadata, and that metadata tells the visual how to treat each level of the hierarchy. If we apply the same metadata to our <em>Date</em> table, we get the same behavior.</p>
<p>This is the TMDL definition of the hidden table generated by auto date/time, stripped of annotations, formats, lineage tags, and summarize attributes:</p>
<pre class="brush: plain; highlight: [7]; notranslate">
table LocalDateTable_eee2517b-a62f-4b3d-a512-4aa237fa2329
    isHidden
    showAsVariationsOnly
    column Date
        dataType: dateTime
        isHidden
        dataCategory: PaddedDateTableDates
        sourceColumn: &#x5B;Date]

    column Year = YEAR(&#x5B;Date])
        dataType: int64
        isHidden
        dataCategory: Years

    column MonthNo = MONTH(&#x5B;Date])
        dataType: int64
        isHidden
        dataCategory: MonthOfYear

    column Month = FORMAT(&#x5B;Date], &quot;MMMM&quot;)
        dataType: string
        isHidden
        dataCategory: Months
        sortByColumn: MonthNo

    column QuarterNo = INT((&#x5B;MonthNo] + 2) / 3)
        dataType: int64
        isHidden
        dataCategory: QuarterOfYear

    column Quarter = &quot;Qtr &quot; &amp;amp; &#x5B;QuarterNo]
        dataType: string
        isHidden
        dataCategory: Quarters
        sortByColumn: QuarterNo

    column Day = DAY(&#x5B;Date])
        dataType: int64
        isHidden
        dataCategory: DayOfMonth
        summarizeBy: none

    hierarchy &#039;Date Hierarchy&#039;
        level Year
            column: Year
        level Quarter
            column: Quarter
        level Month
            column: Month
        level Day
            column: Day
</pre>
<p>Note the dataCategory property on the column: only those on <em>Date</em> and <em>Year</em> matter. Indeed, the dataCategory for <em>Quarter</em> is Quarters when it should be QuarterOfYear, but these intermediate levels between <em>Year</em> and <em>Date</em> are ignored by Power BI.</p>
<h2>The metadata needed</h2>
<p>The line chart provides the continuous axis on a hierarchy when all these conditions are met:</p>
<ol>
<li>The columns come from a <strong>user hierarchy</strong>. Placing the individual columns from a table on the X-axis is not enough; you must use hierarchy levels.</li>
<li>The <strong>lowest level </strong>of the hierarchy is a date column, with dataCategory set to PaddedDateTableDates.</li>
<li>The <strong>top level </strong>of the hierarchy has dataCategory set to Years.</li>
<li>The visual includes only<strong> levels </strong>of the hierarchy starting from the top level marked as Years.</li>
</ol>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-04.svg" width="800" /><br />
That is it. You do not need anything else, but a few practical examples can help!</p>
<p>The date-related values accepted by dataCategory on a column are: Years, Quarters, QuarterOfYear, Months, MonthOfYear, Weeks, WeekOfYear, WeekOfMonth, Days, DayOfYear, DayOfMonth, DayOfWeek, Hours, Minutes, Seconds, Date, PaddedDateTableDates. Power BI Desktop does not show any of them in the Data category dropdown, which only lists geography, URL, image, and barcode categories. You need the TMDL view in Power BI Desktop, Tabular Editor, or the Power BI Modeling MCP server described later.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-05.png" width="300" /></p>
<h2>Configuring the hierarchies</h2>
<p>In the <em>Date</em> table we created in our sample model, we already have columns like <em>Year</em>, <em>Year Month</em> sorted by <em>Year Month Number</em>, and so on. This is a partial definition to highlight the properties to set in the TMDL view of Power BI Desktop, or in Tabular Editor.</p>
<pre class="brush: plain; highlight: [8,13,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39]; notranslate">
table Date
    dataCategory: Time

    column Date
        dataType: dateTime
        isKey
        formatString: mm/dd/yyyy
        dataCategory: PaddedDateTableDates
        sourceColumn: Date

    column Year
        dataType: int64
        dataCategory: Years
        sourceColumn: Year

    column &#039;Year Quarter&#039;
        dataType: string
        isHidden
        sourceColumn: Year Quarter
        sortByColumn: &#039;Year Quarter Number&#039;
&#x5B;...]

    hierarchy Year-Quarter-Month
        level Year
            column: Year
        level Quarter
            column: &#039;Year Quarter&#039;
        level Month
            column: &#039;Year Month Short&#039;
        level Date
            column: Date

    hierarchy Year-Month
        level Year
            column: Year
        level &#039;Year Month&#039;
            column: &#039;Year Month&#039;
        level Date
            column: Date
</pre>
<p>Three things to highlight:</p>
<ul>
<li>The table is marked as a date table. This sets dataCategory: Time on the table and isKey on the <em>Date</em> column. Only the latter (isKey) is required to activate the Continuous axis; the dataCategory property of the table is ignored.</li>
<li>The <em>Date[Date]</em> column has dataCategory: PaddedDateTableDates<strong>.</strong> This is an undocumented but required property to activate the Continuous axis.</li>
<li>The hierarchies start at <em>Year</em> and end at <em>Date</em>. The intermediate levels can be any column with a date-related category.</li>
</ul>
<p>In the following screenshot, you can see the continuous chart used at the quarter and month level of two different hierarchies.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-06.png" width="800" /></p>
<h2>Considerations about visualizations</h2>
<p>The line chart tooltip shows the <em>Year</em> and <em>Month</em> level of the hierarchy, even when the month-level column is <em>Year Month</em>, which already includes the year. For example, in the <em>Year-Month</em> hierarchy, the tooltip displays 2024 twice: once at the year level and again in the month description.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-07.png" width="300" /></p>
<p>This is more visible when we use the <em>Year-Quarter-Month</em> hierarchy: the drill-down to the <em>Month</em> level shows the name in three levels in the tooltip: <em>Year</em>, <em>Quarter</em>, and <em>Month</em>.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-08.png" width="300" /></p>
<p>This is mainly a cosmetic issue, but it is worth noting. To improve the tooltip user experience, you can use the <em>Quarter</em> and <em>Month</em> columns in the <em>Date</em> table to create a hierarchy that shows non-redundant names in the tooltip. For example, this is the tooltip of the <em>Chart-Friendly</em> hierarchy included in the sample file.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-09.png" width="300" /></p>
<p>The metadata does not change the behavior of visuals that do not have a continuous axis type, such as the clustered column chart. The hierarchy works as usual there and in any other visual, including slicers and filters.</p>
<h2>Automating the change with the Power BI Modeling MCP server</h2>
<p>If you use an LLM with the Power BI Authoring MCP server connected to Power BI Desktop, you can describe the configuration instead of writing the TMDL by hand. The server exposes operations on columns and user hierarchies, including the dataCategory property. You can find an updated description of the AI clients available for this task here: <a href="https://docs.sqlbi.com/ai/tools/">AI tools for Power BI Desktop</a>.</p>
<p>Here is a prompt that produces the configuration of the first example:</p>
<blockquote><p>Connect to the semantic model open in Power BI Desktop.<br />
In the table 'Date', set the dataCategory property of these columns without changing any other property:<br />
- Date: PaddedDateTableDates<br />
- Year: Years<br />
Make sure the Date column is key.<br />
Create a user hierarchy named 'Calendar' in 'Date' with these levels in this order:<br />
Year (column Year), Quarter (column 'Quarter'), Month (column 'Month'), Date (column Date).<br />
Do not create, delete, or rename any other object. When done, export the TMDL of the 'Date' table so I can review the result.</p></blockquote>
<p>The LLM completes the action requested smoothly.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-10.png" width="800" /></p>
<p>In Power BI Desktop, we have the new <em>Calendar</em> hierarchy that displays the expected tooltip by selecting a point on the <em>Month</em> level on the Continuous X-axis.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0310-11.png" width="800" /></p>
<h2>Conclusions</h2>
<p>The continuous X-axis for a date hierarchy on a line chart is not a privilege of the auto date/time table. It depends on a few dataCategory values (the most important one being PaddedDateTableDates on the date column) and a user hierarchy that starts with the year and ends with the date. With these properties set through TMDL, Tabular Editor, or an MCP-driven LLM, your <em>Date</em> table offers the same navigation without the downsides of auto date/time.</p>
<p>We covered another approach in a previous article that does not require metadata which is not visible in the Power BI Desktop UI. However, in some cases you may want more control over the name of each level, or other clients you use may not fully support date columns with a custom format for hierarchy levels. The solution in this article may feel more “natural” to users with past experience navigating auto date/time tables.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/continuous-axis-for-any-date-table-in-power-bi/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
	</item>
		<item>
		<title>Understanding DAX contracts when using AI</title>
		<link>https://www.sqlbi.com/tv/understanding-dax-contracts-when-using-ai/</link>
					<comments>https://www.sqlbi.com/tv/understanding-dax-contracts-when-using-ai/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Tue, 06 Oct 2026 10:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=904162</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/QzqSthdmXDw/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>Defining the right contract is a key activity for a DAX developer using AI. Here we introduce the concept of a contract through simple examples.]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/QzqSthdmXDw/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>Defining the right contract is a key activity for a DAX developer using AI. Here we introduce the concept of a contract through simple examples. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/understanding-dax-contracts-when-using-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding DAX contracts when using AI</title>
		<link>https://www.sqlbi.com/articles/understanding-dax-contracts-when-using-ai/</link>
					<comments>https://www.sqlbi.com/articles/understanding-dax-contracts-when-using-ai/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Mon, 05 Oct 2026 20:00:41 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[AI]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=904082</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0309-01-contract-before-dax.png" class="webfeedsFeaturedVisual" /></figure>Defining the right contract is a key activity for a DAX developer using AI. In this article, we introduce the concept of a contract through simple examples. Contract. As a DAX developer, you will use this term frequently; indeed, when&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0309-01-contract-before-dax.png" class="webfeedsFeaturedVisual" /></figure><p>Defining the right contract is a key activity for a DAX developer using AI. In this article, we introduce the concept of a contract through simple examples.<br />
<span id="more-904082"></span></p>
<p><strong><em>Contract</em></strong>. As a DAX developer, you will use this term frequently; indeed, when developing code with an AI assistant, defining the contract is the most important task you need to complete to obtain a useful semantic model.</p>
<p>First things first: what is a contract? In simple terms, it is a text that identifies the rules at work in a specific semantic model. It is not just an algorithm definition: a contract can define multiple measures and multiple algorithms at the same time. However, it is not even a vague description of the model in terms of entities and relationships. It sits somewhere between the two: documentation that defines how to perform calculations in a specific model.</p>
<p>To describe what a contract is, let me indulge for a bit in the evolution of what happened in the world of Business Intelligence over the years. We promise it will be just a few paragraphs, but we feel it is important to properly introduce the contract and put it in the correct perspective.</p>
<h2>How business logic is hidden in code</h2>
<p><img decoding="async" style="float: right;margin: 0 0 0 0;border: none !important" src="https://www.sqlbi.com/wp-content/uploads/C0309-icon-01-users-and-developers.svg" alt="" width="150" height="150" />Once upon a time, there were users and developers. Users wanted reports, but they did not know how to build the models and calculations. Developers could build models and calculations, but they did not know the business details or the specific requirements for calculating over user data. Developers needed precise instructions to write the calculations, and this led to an insane number of endless meetings between users and developers, with the (mostly vain) goal of clearly defining how to compute measures. Developers kept bringing up edge cases where the calculation defined so far would fail, and users got bored by all the details developers were asking for. Eventually it worked, but the friction was real.</p>
<p>Sometimes, young developers (including ourselves!) believed that writing proper documentation upfront would help solve the problem. Therefore, developers wrote insanely complex documentation, and users read it, mostly five minutes before the meeting, because it was just complex and considered unnecessary. Eventually, models were in place, and the real documentation on how the model computed values ended up hidden in DAX (or MDX, at the time) and SQL code. Any update, as you may well imagine, turned into a nightmare.</p>
<p><img loading="lazy" decoding="async" style="float: left;margin: 0 0 0 0;border: none !important" src="https://www.sqlbi.com/wp-content/uploads/C0309-icon-02-logic-hidden-in-code.svg" alt="" width="150" height="150" />With the advent of self-service BI, many users became developers. They no longer needed any documentation because they know the business; instead, they now write Power Query transformations, calculated columns, and complex DAX code to make the semantic model work. Again, the business logic remains hidden in many measures and transformations that often contain serious levels of complexity. The model works for a while but, after a couple of months, nobody knows exactly how it computes the numbers.</p>
<p>The outcome is the same: the business logic remains hidden; the only difference is that the number of models grew immensely.</p>
<p>This scenario is not unique to Business Intelligence: most IT businesses work the same way. Documentation is boring to write, boring to read, mostly non-existent, and, when it exists, it is never up to date. We are pretty sure you know a few Excel files that nobody can understand or modify, but that are crucial to your (or your customer's) business.</p>
<h2>AI changes the role of documentation</h2>
<p>Now that AI assistants are a thing, the scenario is likely to change again, and not for the better. Users will remain users; they no longer need to become expert developers. The AI agent covers the role of developers by writing DAX code, Power Query, or SQL transformations based on the users’ prompts. The number of reports will grow again, and knowledge of how they work will be hidden even further.</p>
<p><img loading="lazy" decoding="async" style="float: right;margin: 0 0 0 0;border: none !important" src="https://www.sqlbi.com/wp-content/uploads/C0309-icon-03-ai-and-contract.svg" alt="" width="150" height="150" />However, there is some good news. Developers hate writing documentation. Users hate reading documentation, not to mention writing it. But… You know who loves both writing and reading documentation? Your AI agent. An agent is not bored by documentation details, and it is also great at taking partial information and correcting the documentation on the fly, keeping information about how a model computes values up to date. An agent is also very good at finding small inconsistencies in your specifications and providing clear examples of when and how they manifest. Finally, agents are extremely good at guiding users through writing concise documentation and verifying that all the code in your semantic model follows the rules defined in the documentation.</p>
<p>The documentation the agent creates is the contract. A contract does not contain anything obvious (like “The customer table contains customers”); it speaks the language of the business, and it defines clear rules to compute values over your data. Those rules need not be defined up-front through meetings. They can be derived by trial and error, and they can be adjusted at any time: every time you discover a behavior that you did not consider in the beginning, you change the measure by changing the contract and asking AI to review the DAX code.</p>
<p>When you write DAX with an AI assistant, the measure is not the most important part of the work. The contract is.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0309-01-contract-before-dax.svg" width="800" /></p>
<h2>Defining a customer ranking contract</h2>
<p>Let me show you a very practical example of how to change your mindset when working with AI. Imagine you want to create a measure to compute the ranking of a customer. The most obvious prompt is something like: “Create a measure to compute the ranking of a customer”, right? Wrong. This is not the right way to approach creating a measure.</p>
<p>Before anything else, you start with the contract, and you use AI to define it through a simple dialogue:</p>
<blockquote><p>I want to compute a customer ranking based on Sales Amount. What questions do we need to answer before we can proceed?</p></blockquote>
<p>The agent answers by asking the most relevant questions you need to answer before even approaching the measure. For example, ChatGPT Astra produces these questions:</p>
<table>
<tbody>
<tr>
<td width="582">Before writing the DAX measure, we need to define what “customer rank” means:</p>
<ol>
<li><strong>Who competes in the ranking?</strong> All customers, only customers selected by slicers, or customers within the same country, region, or segment?</li>
<li><strong>Which filters affect Sales Amount?</strong> Should the ranking reflect the selected dates, products, and other report filters? Should any filters be ignored?</li>
<li><strong>Which direction?</strong> Should the customer with the highest Sales Amount rank <strong>1</strong>?</li>
<li><strong>How should ties work?</strong> For equal sales, use <strong>1, 2, 2, 3</strong> (dense) or <strong>1, 2, 2, 4</strong> (skip)? Or break ties using a unique customer key?</li>
<li><strong>Which customers qualify?</strong> Include or exclude customers with blank sales, zero sales, or negative sales?</li>
<li><strong>What identifies a customer?</strong> Rank individual customer keys, even when names repeat, or group customers by displayed name?</li>
<li><strong>Where will the measure appear?</strong> A customer table, a matrix with subtotals, a card for one selected customer, or a visual filtered to the top customers? What should totals display?</li>
</ol>
<p>These answers define the measure’s contract: the results it must produce as filters and visual context change.</td>
</tr>
</tbody>
</table>
<p>Answering all these questions defines the contract. That is why your next prompt should define the contract, not the measure. We are not going to elaborate on the type of ranking that we want to create. The definition is in the contract, despite our personal way of ranking being quite exotic:</p>
<blockquote><p>Save this contract for the ranking of customers:<br />
- A customer competes with all the customers that purchased at the time of the analysis. For example, if the report shows March 2026 and the first sale is on January 1st 2026, the customer cohort includes all customers who purchased between Jan 1<sup>st</sup> and March 31<sup>st</sup>.<br />
- Customers with no sales are automatically excluded from the ranking because of the previous rule<br />
- All filters need to be considered for the ranking, except for any filter on customers.<br />
- The customer with the highest sales is ranked 1. Ties need to be removed by adding the customer key to the ranking.<br />
- Customers are identified by Customer[CustomerKey]. However, on the matrix, users will use the customer name. In case of ambiguity (multiple customers visible), show a blank.</p></blockquote>
<p>You may think the contract is complete. It is not; unanswered questions remain because we asked the agent to consider the competitor cohort as the list of all customers who purchased anything up to now. This leads to further questions, and the agent highlights them:</p>
<table>
<tbody>
<tr>
<td width="582">Saved in [customer-ranking-contract.md].</p>
<p>Also recorded three unresolved details: selected-period versus cumulative sales for ordering, customer-key tie-break direction, and treatment of historical buyers with no sales in the selected period.</td>
</tr>
</tbody>
</table>
<p>Therefore, the next prompt solves the three open issues:</p>
<blockquote><p>Modify the contract for the ranking of customers, and add these rules:<br />
- use the cumulative sales to produce the ranking<br />
- customer key is added in ascending order to the rank order<br />
- historical buyers with no sales in the selected period participate in the ranking</p></blockquote>
<p>&nbsp;</p>
<p>Please note: so far, we asked it to save the contract, not just use it for the measure. The agent will save its own version of the contract, whose wording is likely to differ from mine and be organized differently. It is always a good idea to show the contract once it has been digested by the agent:</p>
<blockquote><p>Show me the contract used to rank customers</p></blockquote>
<p>In our experience, AI-written contracts are clearer and less ambiguous than what we provided, and you can see that in the answer.</p>
<table>
<tbody>
<tr>
<td width="582"><strong>Customer ranking contract</strong></p>
<p><strong>Customer cohort</strong></p>
<ul>
<li>A customer competes with all customers who have purchased from the first-ever sale through the end of the period being analyzed.</li>
<li>Example: if the first-ever sale is January 1, 2026, and the report shows March 2026, the cohort includes customers who purchased between January 1 and March 31, 2026.</li>
<li>Customers with no sales in this historical window are excluded by this cohort rule.</li>
<li>Historical buyers with no sales in the selected period participate in the ranking.</li>
</ul>
<p><strong>Filter behavior</strong></p>
<ul>
<li>Consider all filters for the ranking except filters on customers.</li>
<li>Apply the historical window described above when determining cohort membership and computing cumulative Sales Amount.</li>
</ul>
<p><strong>Ranking and ties</strong></p>
<ul>
<li>Rank customers by cumulative Sales Amount from the first-ever sale through the end of the period being analyzed, with the highest amount ranked 1.</li>
<li>Eliminate ties by using Customer[CustomerKey] ascending as a secondary ranking criterion. When cumulative Sales Amount is equal, the smaller customer key ranks first.</li>
</ul>
<p><strong>Customer identity and display</strong></p>
<ul>
<li>Identify customers by Customer[CustomerKey].</li>
<li>Users will display customer names in the matrix.</li>
<li>Return blank when the current context contains multiple customers, including when a displayed name corresponds to multiple customer keys.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Now that the contract is well defined, we have obtained several benefits:</p>
<ul>
<li>We have clear, concise documentation of the measure’s behavior. This behavior is easy to understand without even looking at the DAX code, and it can be shared with both AI and humans to discuss the algorithm;</li>
<li>AI has a precise set of instructions to write the DAX code for the measure;</li>
<li>If we must modify this measure in the future, we do not have to review the code; we can speed up development by reading and modifying the contract, then ask AI to modify the measure to adhere to the new contract.</li>
</ul>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0309-02-evolve-the-contract.svg" width="800" /></p>
<p>The last prompt is what we thought should have been the first:</p>
<blockquote><p>Create a measure to compute the ranking of a customer</p></blockquote>
<p>To this last prompt, we obtain the desired measure, which is not trivial:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Customer Rank = 
VAR HasOneCustomer = HASONEVALUE ( Customer&#x5B;CustomerKey] )
VAR CurrentCustomerKey = SELECTEDVALUE ( Customer&#x5B;CustomerKey] )
VAR LastVisibleDate = MAX ( &#039;Date&#039;&#x5B;Date] )
VAR CustomersWithSales =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ( Sales, Customer&#x5B;CustomerKey] ),
            &quot;@CumulativeSales&quot;, &#x5B;Sales Amount]
        ),
        REMOVEFILTERS ( Customer ),
        FILTER (
            ALL ( &#039;Date&#039; ),
            &#039;Date&#039;&#x5B;Date] &amp;lt;= LastVisibleDate
        )
    )
VAR CurrentCustomer =
    FILTER (
        CustomersWithSales,
        Customer&#x5B;CustomerKey] = CurrentCustomerKey
    )
VAR CurrentSales = MAXX ( CurrentCustomer, &#x5B;@CumulativeSales] )
VAR Result =
    IF (
        HasOneCustomer &amp;amp;&amp;amp; COUNTROWS ( CurrentCustomer ) = 1,
        1
            + COUNTROWS (
                FILTER (
                    CustomersWithSales,
                    &#x5B;@CumulativeSales] &amp;gt; CurrentSales
                        || (
                            &#x5B;@CumulativeSales] = CurrentSales
                                &amp;amp;&amp;amp; Customer&#x5B;CustomerKey] &amp;lt; CurrentCustomerKey
                        )
                )
            )
    )
RETURN
    Result
</pre>
<p>The measure is far from perfect; it can probably be written more efficiently using RANK, and, most importantly, it should be carefully validated before going into production. However, these tasks are outside the scope of this article. Here we only wanted to show the process of defining the contract.</p>
<p>You can see the measure at work in the following matrix: Karen Westbrook, for example, ranked first in 2023 but moved to third in 2024 because new customers appeared who purchased more than she did.</p>
<p><img decoding="async" style="border: none" src="https://www.sqlbi.com/wp-content/uploads/C0309-screenshot.png" width="360" /></p>
<p>You can easily see how much easier it is to read the contract than the measure.</p>
<h2>Conclusions</h2>
<p>When developing semantic models, contracts are key to creating calculations successfully. Although it is tempting to do so, you should refrain from creating any measure, no matter how simple, without first creating a contract.</p>
<p>Contracts can be very simple or very complex, but they offer a compact way to store and share details about your semantic model, how values are computed, and any peculiarities in your calculations.</p>
<p>Start getting used to it. Contracts are the new first-class citizens in the BI world; they bring many benefits and, to our knowledge so far, no drawbacks.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/understanding-dax-contracts-when-using-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
	</item>
		<item>
		<title>Start using DAX with AI</title>
		<link>https://www.sqlbi.com/tv/start-using-dax-with-ai/</link>
					<comments>https://www.sqlbi.com/tv/start-using-dax-with-ai/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Wed, 23 Sep 2026 10:00:42 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[AI]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=904180</guid>

					<description><![CDATA[<figure><img src="https://i3.ytimg.com/vi/KtO0BRKHBv4/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>The time has come: in 2026, using AI to write DAX has started to be effective. Latest news and the new courses are at https://www.sqlbi.com/ai/ We also created three new video courses that should not become obsolete in two weeks!&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i3.ytimg.com/vi/KtO0BRKHBv4/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>The time has come: in 2026, using AI to write DAX has started to be effective.<br />
Latest news and the new courses are at <a href="https://www.sqlbi.com/ai/">https://www.sqlbi.com/ai/</a></p>
<p>We also created three new video courses that should not become obsolete in two weeks!<br />
𝗔𝗜 𝗳𝗼𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜: 𝗜𝗻𝘁𝗿𝗼 (𝗳𝗿𝗲𝗲!)<br />
𝗗𝗔𝗫 𝘄𝗶𝘁𝗵 𝗔𝗜: 𝗘𝘀𝘀𝗲𝗻𝘁𝗶𝗮𝗹𝘀<br />
𝗗𝗔𝗫 𝘄𝗶𝘁𝗵 𝗔𝗜: 𝗦𝗰𝗲𝗻𝗮𝗿𝗶𝗼𝘀</p>
<p>Marco wrote a long post to recap what has changed between 2023 and 2026 - see the link below!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/start-using-dax-with-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The hidden complexity of a daily average in DAX</title>
		<link>https://www.sqlbi.com/tv/the-hidden-complexity-of-a-daily-average-in-dax/</link>
					<comments>https://www.sqlbi.com/tv/the-hidden-complexity-of-a-daily-average-in-dax/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Tue, 22 Sep 2026 10:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">http://www.sqlbi.com/?post_type=video&#038;p=903648</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/ajsAULaG_3s/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>A simple daily average can hide complexities and return different values. We explore several edge-case scenarios to build the desired calculation using AI to accelerate the development.]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/ajsAULaG_3s/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>A simple daily average can hide complexities and return different values. We explore several edge-case scenarios to build the desired calculation using AI to accelerate the development.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/the-hidden-complexity-of-a-daily-average-in-dax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Where we stand on AI and DAX in 2026</title>
		<link>https://www.sqlbi.com/blog/marco/2026/09/22/where-we-stand-on-ai-and-dax-in-2026/</link>
					<comments>https://www.sqlbi.com/blog/marco/2026/09/22/where-we-stand-on-ai-and-dax-in-2026/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Tue, 22 Sep 2026 08:30:38 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=blogpost&#038;p=903942</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/timeline-dax-ai-2023-2026-thumbnail.png" class="webfeedsFeaturedVisual" /></figure>The time has come: in 2026, using AI to write DAX has started to be effective. Let me recap what has changed between 2023 and 2026, and what we are doing with our three new courses to best assist you&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/timeline-dax-ai-2023-2026-thumbnail.png" class="webfeedsFeaturedVisual" /></figure><p>The time has come: in 2026, <strong>using AI to write DAX has started to be effective</strong>. Let me recap what has changed between 2023 and 2026, and what we are doing with our three new courses to best assist you through these changes.<br />
<span id="more-903942"></span></p>
<p><img loading="lazy" decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/icon-developer.png" alt="Laptop with code brackets" width="150" height="150" /></p>
<p>I started my career as a developer: Basic, Assembler, Pascal, C, C++, Delphi, C#, and many other specific domain languages along the way. Writing code is magical and time-consuming. Over time, I shifted my focus to data analytics, but I never stopped coding. Much less, and with much less time, with many more compromises. In the last two years, the support of AI to improve developer productivity has been absolutely amazing, from completing one line of code to writing complete files and now managing entire repos. This should be the introduction to another article, because this one is about DAX: why does my second life as a developer matter?</p>
<p>The reason is that, while I adopted AI relatively early to write software, I was not enthusiastic about using AI to write DAX code. Fourteen months ago, in July 2025, I wrote a <a href="https://www.sqlbi.com/blog/marco/2025/07/28/a-few-thoughts-about-newsletter-300-and-ai/">post for the 300th edition of our Newsletter</a> to clarify the position of SQLBI on AI. The message was that AI speeds up specific tasks, that the end-to-end time savings were smaller than what you would have expected from faster prototype creation, and that we would write about AI only when we saw clear, measurable benefits.</p>
<p>You might think that it was a conflict-of-interest type of situation: after all, I have been teaching DAX for a living for many years. But no, that was not the reason, because in teaching, my goal has always been to help people achieve their goals faster and more efficiently. Other topics simply become important as technology evolves. I waited, simply because AI was not ready for DAX. Hey, have you heard people say DAX is hard? Well, I don't think it is hard; it's just different, and AI learns by example, adapting and generalizing concepts across languages. But with DAX, that wasn't entirely possible, because it’s unique (and beautiful!) in its own way.</p>
<p>Well, I have big news. <strong>The wait is over; the time has come. </strong>Writing DAX with AI started to make sense this year. The acceleration we've seen in DAX proficiency with the new frontier models released in the last six months has been incredible. We are not at the “perfect” level; performance could still be a weakness, but we are well past the point of considering it helpful. Today, we use AI every day to transform data, create and modify semantic models, and draft long, complex DAX code! We published two articles in August about using AI to write DAX.</p>
<p>So, I have news about our upcoming training and about clarifying our position at SQLBI on using AI to write DAX: long-time readers of this blog know that we have been cautious about using AI to write DAX. Clearly, something changed, and if you are interested, I want to recap the journey since the first experiments with AI in DAX and explain our current position. Sit down, relax, and enjoy the read.</p>
<h2>The new courses</h2>
<p>We recently created three courses for different steps in using AI to write DAX:</p>
<ul>
<li><a href="https://www.sqlbi.com/p/ai-for-powerbi-intro-video-course/"><strong>AI for Power BI: Intro</strong><img decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/ai-for-powerbi-intro-email.png" alt="AI for Power BI: Intro (logo)" width="100" /></a> to understand the basics of AI in Power BI. This is not about Copilot; it is about using agents, skills, plugins, and MCP servers to manipulate Power BI models and reports. If you already use your Claude Code connected to Power BI, you probably already have this knowledge. If you are still using ChatGPT in a web browser by copying and pasting DAX code, you definitely need to learn the foundational concepts that apply to this new way of working, regardless of the specific tool. The tool choice doesn’t really matter, as long as it connects to MCP servers.</li>
<li><a href="https://www.sqlbi.com/p/dax-with-ai-essentials-video-course/"><img decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-essentials.png" alt="DAX with AI: Essentials (logo)" width="100" /><strong>DAX with AI: Essentials</strong></a> to learn how to read the DAX code generated by AI tools. If you already know DAX, you will see how to write correct prompts and how to actually use the agents to write measures. If you already know the AI tools but you are new to DAX, you will learn how to read DAX even if you are not able to write it.</li>
<li><a href="https://www.sqlbi.com/p/dax-with-ai-scenarios-video-course/"><img decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/dax-with-ai-scenarios.png" alt="DAX with AI: Scenarios (logo)" width="100" /><strong>DAX with AI: Scenarios</strong></a> to deal with more complex scenarios where your work is mainly to control the direction of the development, which includes writing DAX code and modifying the model so that it generates the correct result for the business problem described. This course can be seen as a library of business scenarios you can use to create a specific solution or to learn generic techniques applied to different use cases. The course also includes foundational concepts (specific data modeling and DAX techniques) which you can apply to several scenarios. You can pick only the foundational concepts you need for the use case you are interested in, or you can just go through the whole course from A to Z. You have options.</li>
</ul>
<p>The courses are built with two distinct profiles in mind. The first is someone who doesn't know DAX, uses an LLM (or would like to), and wants better results; this person needs to learn enough DAX to understand what the model produces. The second is someone who already knows DAX and mainly uses AI to copy-and-paste DAX code from a chat window. Our new courses are more complete for the first profile, while they provide tremendous guidance on the right combination of tools and prompts to be more efficient and effective for the second profile. That profile will also use this as an opportunity to validate their DAX knowledge in a new context.</p>
<p>In these courses, we don't teach AI tools because they change so often that a course can become obsolete before it is even published. This also means it doesn’t matter whether you use Visual Studio Code, Claude, Codex, other tools, or one day a chat integrated into Power BI (we all would like that, right?). We provide help installing it on separate pages that we'll keep up to date, but the courses focus on using AI effectively for DAX development.</p>
<p>We focus on how you write the request, we offer reasoning about the problem, we give instructions, and we check the result. Many AI videos for Power BI assume you already know the tools or show what's possible without explaining what matters when you use it for work. We focused on teaching without worrying about the demo effect.</p>
<p>But what about all the other courses? <strong>Are they still relevant?</strong> Yes, you will just use those skills in a different way. But let’s ask different AI models; I wrote the following prompt:</p>
<blockquote><p><strong>Is it worth attending a DAX training now that AI can write good DAX code?</strong></p></blockquote>
<p>Here are the answers from three frontier models – no cherry picking!</p>
<p><!-- Complete AI responses. --></p>
<div id="sqlbi-dax-ai-answers" style="box-sizing: border-box; width: 100%; max-width: 100%; margin: 28px 0; border: 1px solid #ccd1d6; border-radius: 6px; background: #fff; color: #222; font-family: inherit; font-size: 16px; line-height: 1.65; overflow-wrap: anywhere;">
<div style="display: flex; flex-wrap: wrap; gap: 0; margin: 0; padding: 0; background: #f3f4f5; border-bottom: 1px solid #ccd1d6; border-radius: 6px 6px 0 0; overflow: hidden;" data-ai-tabs="" aria-label="Choose an AI response"><a id="sqlbi-ai-tab-gpt" style="box-sizing: border-box; flex: 1 1 180px; display: block; margin: 0; padding: 13px 12px; border: 0; border-top: 3px solid transparent; background: transparent; color: #454b52; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.4; text-align: center; text-decoration: none; cursor: pointer; outline-offset: -3px;" href="#sqlbi-ai-panel-gpt" data-ai-tab="">GPT-6 Astra Light</a><br />
<a id="sqlbi-ai-tab-fable" style="box-sizing: border-box; flex: 1 1 180px; display: block; margin: 0; padding: 13px 12px; border: 0; border-top: 3px solid transparent; background: transparent; color: #454b52; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.4; text-align: center; text-decoration: none; cursor: pointer; outline-offset: -3px;" href="#sqlbi-ai-panel-fable" data-ai-tab="">Fable 5.1 High</a><br />
<a id="sqlbi-ai-tab-grok" style="box-sizing: border-box; flex: 1 1 180px; display: block; margin: 0; padding: 13px 12px; border: 0; border-top: 3px solid transparent; background: transparent; color: #454b52; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.4; text-align: center; text-decoration: none; cursor: pointer; outline-offset: -3px;" href="#sqlbi-ai-panel-grok" data-ai-tab="">Grok 4.6 Expert</a></div>
<section id="sqlbi-ai-panel-gpt" style="box-sizing: border-box; padding: 22px clamp(14px,4%,28px);" data-ai-panel="" aria-labelledby="sqlbi-ai-tab-gpt">
<h3 style="margin: 0 0 1em; font-size: 1.15em;" data-ai-fallback-heading="">GPT-6 Astra Light</h3>
<div style="display: block; box-sizing: border-box; width: 100%; max-width: none; float: none; margin: 0 0 22px; padding: 11px 14px; border-left: 3px solid #aab2ba; background: #f3f4f5; color: #555e67; font-family: Arial,sans-serif; font-size: 13px; line-height: 1.5;" role="note">Original conversation available at <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px;" href="https://chatgpt.com/share/6aad0916-1508-83eb-bb5a-20c15e8a3e0f" target="_blank" rel="noopener noreferrer">ChatGPT (opens in a new tab)</a>.<br />
<span style="font-size: 12px;">Editorial source note — not part of the AI response.</span></div>
<div data-ai-answer="">
<p style="margin: 0 0 1em; padding: 0;">Yes—<strong>but the reason to attend DAX training in 2026 is different from what it was a few years ago</strong>.</p>
<p style="margin: 0 0 1em; padding: 0;">AI has substantially reduced the value of learning DAX syntax by heart. It has <strong>not</strong> eliminated the value of understanding how DAX actually evaluates expressions.</p>
<p style="margin: 0 0 1em; padding: 0;">Microsoft’s own current guidance reflects this. Copilot can generate DAX queries and measures, but Microsoft specifically warns that it can struggle with variables, calculation groups, newer DAX syntax, and other cases, and recommends understanding/reviewing generated code rather than blindly accepting it. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://learn.microsoft.com/en-us/power-bi/create-reports/copilot-semantic-models?utm_source=chatgpt.com">Microsoft Learn</a></p>
<h3 style="margin: 1.5em 0 .65em; padding: 0; font-size: 1.15em; line-height: 1.4; font-weight: bold; color: #222;">What AI changes</h3>
<div style="max-width: 100%; overflow-x: auto; margin: 0 0 1em;" tabindex="0" role="region" aria-label="Comparison table">
<table style="min-width: 520px; width: 100%; margin: 0 0 1em; border-collapse: collapse; table-layout: fixed; font-size: .94em;">
<thead>
<tr>
<th style="padding: 10px; border: 1px solid #d8dde2; background: #f3f4f5; text-align: left; vertical-align: top; font-weight: bold;" scope="col">Skill</th>
<th style="padding: 10px; border: 1px solid #d8dde2; background: #f3f4f5; text-align: left; vertical-align: top; font-weight: bold;" scope="col">Before AI</th>
<th style="padding: 10px; border: 1px solid #d8dde2; background: #f3f4f5; text-align: left; vertical-align: top; font-weight: bold;" scope="col">With good AI</th>
<th style="padding: 10px; border: 1px solid #d8dde2; background: #f3f4f5; text-align: left; vertical-align: top; font-weight: bold;" scope="col">Training value</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Remembering function names</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Important</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Mostly unnecessary</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Low</td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Writing routine measures</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Important</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">AI is very good</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Low–medium</td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Looking up syntax</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Important</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Nearly automated</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Low</td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Filter context</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Essential</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Still essential</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;"><strong>Very high</strong></td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Context transition</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Essential</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">AI can write it, but you must understand consequences</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;"><strong>Very high</strong></td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Data-model/DAX interaction</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Essential</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">AI often lacks enough model intent</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;"><strong>Very high</strong></td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Debugging wrong totals</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Difficult</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">AI helps, but doesn't remove reasoning</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;"><strong>High</strong></td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Choosing between valid DAX patterns</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Expert skill</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">AI can propose alternatives</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;"><strong>High</strong></td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Performance optimization</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Expert skill</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">AI helps inconsistently</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;"><strong>High</strong></td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Reviewing AI-generated DAX</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Didn't exist</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">Increasingly important</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;"><strong>Very high</strong></td>
</tr>
</tbody>
</table>
</div>
<p style="margin: 0 0 1em; padding: 0;">The key distinction is:</p>
<p style="margin: 0 0 1em; padding: 0;"><strong>Writing DAX ≠ understanding DAX.</strong></p>
<p style="margin: 0 0 1em; padding: 0;">Suppose you ask AI:</p>
<blockquote style="display: block; box-sizing: border-box; width: 100%; max-width: none; float: none; margin: 0 0 1em; padding: 12px 16px 0; border-left: 3px solid #ccd1d6; font: inherit; color: inherit;">
<p style="margin: 0 0 1em; padding: 0;">"Calculate sales for customers whose lifetime sales exceed €10,000, preserving the product filter but ignoring the current customer selection."</p>
</blockquote>
<p style="margin: 0 0 1em; padding: 0;">A modern model can probably produce plausible DAX immediately.</p>
<p style="margin: 0 0 1em; padding: 0;">The difficult questions are now:</p>
<ul style="margin: 0 0 1em; padding: 0 0 0 1.5em; list-style: disc outside;">
<li style="margin: 0 0 .6em; padding: 0;">
<p style="margin: 0 0 1em; padding: 0;">Is it computing customer lifetime sales in the intended context?</p>
</li>
<li style="margin: 0 0 .6em; padding: 0;">
<p style="margin: 0 0 1em; padding: 0;">Should the customer filter be removed with <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">ALL</code>, <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">REMOVEFILTERS</code>, <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">ALLSELECTED</code>, or something else?</p>
</li>
<li style="margin: 0 0 .6em; padding: 0;">
<p style="margin: 0 0 1em; padding: 0;">When is the measure evaluated?</p>
</li>
<li style="margin: 0 0 .6em; padding: 0;">
<p style="margin: 0 0 1em; padding: 0;">Does context transition occur?</p>
</li>
<li style="margin: 0 0 .6em; padding: 0;">
<p style="margin: 0 0 1em; padding: 0;">Will totals behave correctly?</p>
</li>
<li style="margin: 0 0 .6em; padding: 0;">
<p style="margin: 0 0 1em; padding: 0;">What happens with many-to-many relationships?</p>
</li>
<li style="margin: 0 0 .6em; padding: 0;">
<p style="margin: 0 0 1em; padding: 0;">Does the expression scale to a 500-million-row model?</p>
</li>
</ul>
<p style="margin: 0 0 1em; padding: 0;">Those aren't primarily syntax questions. They are <strong>semantic-model reasoning questions</strong>.</p>
<p style="margin: 0 0 1em; padding: 0;">Microsoft still describes understanding context as critical both for producing dynamic calculations and for troubleshooting formulas. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://learn.microsoft.com/en-us/dax/dax-overview?utm_source=chatgpt.com">Microsoft Learn</a> And its intermediate DAX training continues to emphasize <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">CALCULATE</code>, filter context, filter modifiers and context transition rather than merely teaching function syntax. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://learn.microsoft.com/en-us/training/modules/dax-power-bi-modify-filter/?utm_source=chatgpt.com">Microsoft Learn</a></p>
<h3 style="margin: 1.5em 0 .65em; padding: 0; font-size: 1.15em; line-height: 1.4; font-weight: bold; color: #222;">So is a serious DAX course still worth the money?</h3>
<p style="margin: 0 0 1em; padding: 0;">I'd divide people into three groups.</p>
<table style="width: 100%; margin: 0 0 1em; border-collapse: collapse; table-layout: fixed; font-size: .94em;">
<thead>
<tr>
<th style="padding: 10px; border: 1px solid #d8dde2; background: #f3f4f5; text-align: left; vertical-align: top; font-weight: bold;" scope="col">Your situation</th>
<th style="padding: 10px; border: 1px solid #d8dde2; background: #f3f4f5; text-align: left; vertical-align: top; font-weight: bold;" scope="col">Value of intensive DAX training</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">You make reports and mostly need SUM, ratios, YTD, basic comparisons</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">★★☆☆☆</td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">You develop production Power BI semantic models</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">★★★★☆</td>
</tr>
<tr>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">You design complex models, troubleshoot DAX, optimize calculations, or advise other developers</td>
<td style="padding: 10px; border: 1px solid #d8dde2; text-align: left; vertical-align: top;">★★★★★</td>
</tr>
</tbody>
</table>
<p style="margin: 0 0 1em; padding: 0;">For the first group, I'd probably learn interactively with AI plus Microsoft Learn rather than spend several days in advanced classroom training.</p>
<p style="margin: 0 0 1em; padding: 0;">For the second and third groups, the economics have arguably become <strong>better</strong>, not worse: AI lets you skip a lot of mechanical coding and spend more of your time understanding the difficult parts.</p>
<p style="margin: 0 0 1em; padding: 0;">A course such as SQLBI's current <strong>Mastering DAX</strong> reflects that distinction. The 2026 curriculum includes filter/row context, table functions, semi-additive calculations, calculation groups, advanced relationships, window functions, time intelligence and what happens "inside CALCULATE"—topics considerably deeper than simply learning how to type measures. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://www.sqlbi.com/p/mastering-dax-workshop-berlin-jun-15-17-2026/">SQLBI</a> The new video course also explicitly spends significant time building an understanding of filter context from the ground up. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://www.sqlbi.com/blog/marco/2026/04/01/the-third-edition-of-the-mastering-dax-video-course-unplugged/">SQLBI</a></p>
<h3 style="margin: 1.5em 0 .65em; padding: 0; font-size: 1.15em; line-height: 1.4; font-weight: bold; color: #222;">The skill stack I think matters now</h3>
<pre style="margin: 0 0 1em; padding: 14px; background: #f3f4f5; border: 1px solid #dde1e5; border-radius: 4px; overflow-x: auto; white-space: pre; font-size: .9em; line-height: 1.6; color: #222;"><code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">                    2020                         2026
             ─────────────────             ─────────────────
                 DAX syntax                    DAX semantics
               function recall                 filter context
              pattern knowledge               model reasoning
                   ↓                               ↓
             write the code               describe the intent
                                                ↓
                                           AI writes code
                                                ↓
                                      YOU verify correctness
                                                ↓
                                      YOU diagnose edge cases</code></pre>
<p style="margin: 0 0 1em; padding: 0;">The interesting consequence is that <strong>AI makes shallow DAX knowledge less valuable and deep DAX knowledge more valuable</strong>.</p>
<p style="margin: 0 0 1em; padding: 0;">Someone who knows only syntax is increasingly replaceable by AI.</p>
<p style="margin: 0 0 1em; padding: 0;">Someone who understands evaluation context, relationships, expanded tables, lineage, context transition and engine behavior can use AI as an extremely fast DAX assistant—and can recognize when it produces something subtly wrong.</p>
<p style="margin: 0 0 1em; padding: 0;">So if the proposed training is essentially <strong>"here are 100 DAX functions"</strong>, I would be reluctant to invest much time in it.</p>
<p style="margin: 0 0 1em; padding: 0;">If it is training in <strong>how DAX works</strong>, particularly something at the level of Mastering DAX, I think it remains highly relevant. The objective shouldn't be <em>"after three days I can write DAX without AI."</em> It should be:</p>
<blockquote style="display: block; box-sizing: border-box; width: 100%; max-width: none; float: none; margin: 0 0 1em; padding: 12px 16px 0; border-left: 3px solid #ccd1d6; font: inherit; color: inherit;">
<p style="margin: 0 0 1em; padding: 0;"><strong>"After three days I can tell AI what calculation I actually need, understand what it generated, and know when it is wrong."</strong></p>
</blockquote>
<p style="margin: 0 0 1em; padding: 0;">That is probably the more durable DAX skill now.</p>
</div>
</section>
<section id="sqlbi-ai-panel-fable" style="box-sizing: border-box; padding: 22px clamp(14px,4%,28px);" data-ai-panel="" aria-labelledby="sqlbi-ai-tab-fable">
<h3 style="margin: 0 0 1em; font-size: 1.15em;" data-ai-fallback-heading="">Fable 5.1 High</h3>
<div style="display: block; box-sizing: border-box; width: 100%; max-width: none; float: none; margin: 0 0 22px; padding: 11px 14px; border-left: 3px solid #aab2ba; background: #f3f4f5; color: #555e67; font-family: Arial,sans-serif; font-size: 13px; line-height: 1.5;" role="note">Original conversation available at <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px;" href="https://claude.ai/share/39c907ae-68d3-496e-a9bf-793e09e69998" target="_blank" rel="noopener noreferrer">Claude (opens in a new tab)</a>.<br />
<span style="font-size: 12px;">Editorial source note — not part of the AI response.</span></div>
<div data-ai-answer="">
<p style="margin: 0 0 1em; padding: 0;">Yes, though the reason has shifted. AI has made the <em>typing</em> of DAX cheap, and that changes what training is for.</p>
<p style="margin: 0 0 1em; padding: 0;">The part AI handles well is translating a clear intent into syntax: "total sales for the same period last year, only for products in the current filter" becomes a working measure in seconds. What it does not do is know whether that measure is the right one for your model, and you will not know either unless you understand the underlying mechanics.</p>
<p style="margin: 0 0 1em; padding: 0;">A few things that still require you to actually understand DAX:</p>
<p style="margin: 0 0 1em; padding: 0;">Evaluation context. Most wrong DAX is not syntactically wrong; it returns a plausible number that is subtly incorrect because of filter context, context transition, or an unexpected interaction with the relationship. AI-generated code fails this way just as often as human code, and the failure is invisible unless you can reason about what the engine is doing. Reviewing a measure is a skill, and it is the same skill as writing one.</p>
<p style="margin: 0 0 1em; padding: 0;">Specification. To ask for the right thing, you have to know what "the right thing" is in DAX terms. "Same period last year" is ambiguous in a fiscal calendar with 53-week years; "ranking" hides a dozen decisions about ties and filters. The training gives you the vocabulary to ask precisely and to recognise when the answer solved a different problem.</p>
<p style="margin: 0 0 1em; padding: 0;">Modeling and performance. Much of what looks like a DAX problem is a data model problem. AI will happily write a 40-line measure to work around a missing relationship or a badly shaped fact table, and it will run slowly. Knowing when to fix the model instead is judgment, not code generation.</p>
<p style="margin: 0 0 1em; padding: 0;">Accountability. If the number in the CFO's report is wrong, "the AI wrote it" is not an answer. Someone has to be able to verify it.</p>
<p style="margin: 0 0 1em; padding: 0;">So the honest reframe is: training is now less about learning to produce code and more about learning to evaluate it, direct it, and know when to distrust it. That is arguably more valuable, not less, because the leverage is higher — one person who understands DAX plus an AI can do the work of several who don't, while several who don't plus an AI mostly produce confident errors faster.</p>
<p style="margin: 0 0 1em; padding: 0;">Where I'd be more skeptical: a course that is mainly syntax drills and function reference is worth less than it was. Look for training built around how the engine evaluates expressions and how to reason about results, and ideally one that acknowledges AI as a tool you'll be using alongside it.</p>
</div>
</section>
<section id="sqlbi-ai-panel-grok" style="box-sizing: border-box; padding: 22px clamp(14px,4%,28px);" data-ai-panel="" aria-labelledby="sqlbi-ai-tab-grok">
<h3 style="margin: 0 0 1em; font-size: 1.15em;" data-ai-fallback-heading="">Grok 4.6 Expert</h3>
<div style="display: block; box-sizing: border-box; width: 100%; max-width: none; float: none; margin: 0 0 22px; padding: 11px 14px; border-left: 3px solid #aab2ba; background: #f3f4f5; color: #555e67; font-family: Arial,sans-serif; font-size: 13px; line-height: 1.5;" role="note">Original conversation available at <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px;" href="https://grok.com/share/bGVnYWN5LWNvcHk_5092e858-6f64-4b22-885f-7ed9f666df06" target="_blank" rel="noopener noreferrer">Grok (opens in a new tab)</a>.<br />
<span style="font-size: 12px;">Editorial source note — not part of the AI response.</span></div>
<div data-ai-answer="">
<p style="margin: 0 0 1em; padding: 0;"><strong>Yes — if you will own models or numbers that matter.</strong> AI is a strong junior pair-programmer for DAX, not a replacement for understanding it.</p>
<p style="margin: 0 0 1em; padding: 0;">AI (Power BI Copilot, ChatGPT, Claude, etc.) is now good at <em>writing</em> common DAX: simple aggregations, basic <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">CALCULATE</code> filters, standard time intelligence. That part of the job is cheaper than it was two years ago. What it is still weak at is the part that actually breaks reports. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://lets-viz.com/blogs/dax-pattern-breaks-ai-copilots-2026/">Lets-viz</a></p>
<h3 style="margin: 1.5em 0 .65em; padding: 0; font-size: 1.15em; line-height: 1.4; font-weight: bold; color: #222;">What AI still gets wrong</h3>
<p style="margin: 0 0 1em; padding: 0;">Independent 2026 benchmarks are consistent:</p>
<ul style="margin: 0 0 1em; padding: 0 0 0 1.5em; list-style: disc outside;">
<li style="margin: 0 0 .6em; padding: 0;">Copilot on structured DAX tests: about <strong>62.5% fully reliable</strong>. The rest looks plausible and is wrong in a subtle way. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://lets-viz.com/blogs/dax-pattern-breaks-ai-copilots-2026/">Lets-viz</a></li>
<li style="margin: 0 0 .6em; padding: 0;">Broader LLM tests: models often get the <em>intent</em> right and the <em>DAX grammar or evaluation</em> wrong. One large benchmark found far more syntax failures than logic failures; <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">RANKX</code> alone caused a huge share of compile errors. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://maxanatsko.com/blog/i-tested-70-ai-models-on-dax-heres-what-actually-works">Maxanatsko</a></li>
<li style="margin: 0 0 .6em; padding: 0;">The pattern that reliably breaks copilots is <strong>context transition</strong> — iterators like <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">SUMX</code> / <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">AVERAGEX</code> / <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">RANKX</code> that reference measures instead of columns. Custom fiscal calendars and messy many-to-many models are also frequent failure modes. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://lets-viz.com/blogs/dax-pattern-breaks-ai-copilots-2026/">Lets-viz</a></li>
</ul>
<p style="margin: 0 0 1em; padding: 0;">The dangerous cases are not red-error formulas. They are measures that total correctly on one visual and lie on another because grain, filter context, or a relationship was misunderstood.</p>
<p style="margin: 0 0 1em; padding: 0;">Microsoft’s own docs say Copilot can use the wrong functions, mishandle variables, and that inexperienced authors must validate everything before using it. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://learn.microsoft.com/en-us/power-bi/create-reports/copilot-semantic-models">Learn.microsoft</a></p>
<h3 style="margin: 1.5em 0 .65em; padding: 0; font-size: 1.15em; line-height: 1.4; font-weight: bold; color: #222;">Why that still justifies training</h3>
<p style="margin: 0 0 1em; padding: 0;">DAX is not Excel-with-funny-names. The hard skill is <strong>evaluation context</strong>: row context, filter context, context transition, grain, and how relationships change a number. That is also what AI is worst at.</p>
<p style="margin: 0 0 1em; padding: 0;">SQLBI (Marco Russo and Alberto Ferrari) shipped a <em>third</em> edition of Mastering DAX in 2026 <em>after</em> LLMs arrived. Their reasons to still learn it: generated DAX still has to be validated; a short correct formula is often cheaper than a long prompt; knowing the language makes you write better prompts; and “the moment you stop thinking, you become disposable.” Your value is the corrections the model still needs — in DAX, often more than 5–10%, especially if you also care about performance. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://www.sqlbi.com/articles/mastering-dax-video-course-3rd-edition/">Sqlbi</a></p>
<p style="margin: 0 0 1em; padding: 0;">The same pattern shows up across practitioner write-ups in 2026:</p>
<ul style="margin: 0 0 1em; padding: 0 0 0 1.5em; list-style: disc outside;">
<li style="margin: 0 0 .6em; padding: 0;">Copilot quality tracks <strong>model quality</strong>. Clean names, relationships, and measure descriptions make AI useful. A messy model makes it confidently wrong. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://towardsdatascience.com/the-power-bi-developers-survival-guide-to-microsoft-fabric/">Towardsdatascience</a></li>
<li style="margin: 0 0 .6em; padding: 0;">In Fabric, DAX and the semantic layer got <em>more</em> important, not less: Copilot, Direct Lake, and data agents all sit on measures you define. Bad DAX pollutes every AI feature downstream. <a style="color: #9e281f; text-decoration: underline; text-underline-offset: 2px; font-size: .85em;" href="https://towardsdatascience.com/the-power-bi-developers-survival-guide-to-microsoft-fabric/">Towardsdatascience</a></li>
</ul>
<p style="margin: 0 0 1em; padding: 0;">So the job is shifting from “type the formula” to:</p>
<ol style="margin: 0 0 1em; padding: 0 0 0 1.5em; list-style: decimal outside;">
<li style="margin: 0 0 .6em; padding: 0;">Specify the business rule precisely (grain, filters, what a blank means).</li>
<li style="margin: 0 0 .6em; padding: 0;">Keep the model AI-readable.</li>
<li style="margin: 0 0 .6em; padding: 0;">Check results at multiple grains (row, group, total).</li>
<li style="margin: 0 0 .6em; padding: 0;">Catch inefficient iterators before they hit production.</li>
<li style="margin: 0 0 .6em; padding: 0;">Know when the generated pattern is the wrong pattern.</li>
</ol>
<p style="margin: 0 0 1em; padding: 0;">You cannot do 3–5 if you only know how to paste.</p>
<h3 style="margin: 1.5em 0 .65em; padding: 0; font-size: 1.15em; line-height: 1.4; font-weight: bold; color: #222;">When training is <em>not</em> worth much</h3>
<p style="margin: 0 0 1em; padding: 0;">Skip a multi-day DAX workshop if:</p>
<ul style="margin: 0 0 1em; padding: 0 0 0 1.5em; list-style: disc outside;">
<li style="margin: 0 0 .6em; padding: 0;">You only build simple dashboards (<code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">SUM</code>, <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">COUNT</code>, basic YoY) and someone else owns the model.</li>
<li style="margin: 0 0 .6em; padding: 0;">You will never be the person who has to explain a number to finance or audit.</li>
<li style="margin: 0 0 .6em; padding: 0;">The course is a function catalog (“here are 80 DAX functions”) rather than context and modeling.</li>
</ul>
<p style="margin: 0 0 1em; padding: 0;">For that profile, Copilot plus a good model and a short “how to verify a measure” habit is enough.</p>
<h3 style="margin: 1.5em 0 .65em; padding: 0; font-size: 1.15em; line-height: 1.4; font-weight: bold; color: #222;">What is still worth paying for</h3>
<p style="margin: 0 0 1em; padding: 0;">Invest in training that covers the parts AI does not internalize:</p>
<ul style="margin: 0 0 1em; padding: 0 0 0 1.5em; list-style: disc outside;">
<li style="margin: 0 0 .6em; padding: 0;">Filter context, <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">CALCULATE</code>, <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">KEEPFILTERS</code>, context transition</li>
<li style="margin: 0 0 .6em; padding: 0;">Grain and why a measure can be right in the detail and wrong in the total</li>
<li style="margin: 0 0 .6em; padding: 0;">Star-schema modeling (this multiplies AI accuracy more than any prompt trick)</li>
<li style="margin: 0 0 .6em; padding: 0;">How to test a measure (DAX Query View, different slicer combinations, blank handling)</li>
<li style="margin: 0 0 .6em; padding: 0;">Performance: when <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">SUMX</code> is necessary vs lazy</li>
<li style="margin: 0 0 .6em; padding: 0;">How to use Copilot as a draft + review loop, not as an oracle</li>
</ul>
<p style="margin: 0 0 1em; padding: 0;">That is a different syllabus from “learn DAX because you cannot remember <code style="font-family: Consolas,Monaco,monospace; font-size: .94em; color: inherit;">SAMEPERIODLASTYEAR</code>.” Syntax training is largely obsolete. Conceptual training is not.</p>
<p style="margin: 0 0 1em; padding: 0;"><strong>Practical rule:</strong> if a wrong number would change a decision, you still need enough DAX to distrust the model. AI made mediocre DAX cheaper. It made <em>good</em> DAX more valuable, because someone has to own the last 20%.</p>
</div>
</section>
</div>
<p><script>
(function () {
  "use strict";
  var root = document.getElementById("sqlbi-dax-ai-answers");
  if (!root || root.getAttribute("data-ai-ready")) return;
  var tabs = Array.prototype.slice.call(root.querySelectorAll("[data-ai-tab]"));
  var panels = Array.prototype.slice.call(root.querySelectorAll("[data-ai-panel]"));
  var headings = root.querySelectorAll("[data-ai-fallback-heading]");
  var tablist = root.querySelector("[data-ai-tabs]");
  var selected = 0;
  function select(index, focus) {
    selected = index;
    tabs.forEach(function (tab, i) {
      var active = i === index;
      tab.setAttribute("aria-selected", String(active));
      tab.tabIndex = active ? 0 : -1;
      tab.style.backgroundColor = active ? "#fff" : "transparent";
      tab.style.color = active ? "#9e281f" : "#454b52";
      tab.style.borderTopColor = active ? "#b53026" : "transparent";
      panels[i].hidden = !active;
      panels[i].style.display = active ? "block" : "none";
    });
    if (focus) tabs[index].focus();
  }
  tablist.setAttribute("role", "tablist");
  tabs.forEach(function (tab, index) {
    tab.setAttribute("role", "tab");
    tab.setAttribute("aria-controls", panels[index].id);
    panels[index].setAttribute("role", "tabpanel");
    panels[index].tabIndex = 0;
    panels[index].style.maxHeight = "640px";
    panels[index].style.overflowY = "auto";
    tab.addEventListener("click", function (event) {
      event.preventDefault();
      select(index, false);
    });
    tab.addEventListener("keydown", function (event) {
      var next = index;
      if (event.key === "ArrowRight") next = (index + 1) % tabs.length;
      else if (event.key === "ArrowLeft") next = (index + tabs.length - 1) % tabs.length;
      else if (event.key === "Home") next = 0;
      else if (event.key === "End") next = tabs.length - 1;
      else if (event.key !== " " && event.key !== "Enter") return;
      event.preventDefault();
      select(next, true);
    });
  });
  Array.prototype.forEach.call(headings, function (heading) { heading.style.display = "none"; });
  var initial = panels.findIndex(function (panel) { return "#" + panel.id === window.location.hash; });
  select(initial < 0 ? 0 : initial, false);
  root.setAttribute("data-ai-ready", "true");
  window.addEventListener("beforeprint", function () {
    tablist.style.display = "none";
    panels.forEach(function (panel) {
      panel.hidden = false;
      panel.style.display = "block";
      panel.style.maxHeight = "none";
      panel.style.overflowY = "visible";
    });
    Array.prototype.forEach.call(headings, function (heading) { heading.style.display = "block"; });
  });
  window.addEventListener("afterprint", function () {
    tablist.style.display = "flex";
    panels.forEach(function (panel) { panel.style.maxHeight = "640px"; panel.style.overflowY = "auto"; });
    Array.prototype.forEach.call(headings, function (heading) { heading.style.display = "none"; });
    select(selected, false);
  });
}());
</script></p>
<p>The classroom courses on DAX do not change. If you attend one, you will learn to write and read DAX, and you need to read it to check the code the AI writes. Of course, we are also integrating into the in-person courses how to use the AI tools in the context of DAX development.</p>
<p>And now, the full story behind this change.</p>
<p><a href="https://www.sqlbi.com/wp-content/uploads/timeline-dax-ai-2023-2026.svg"><img loading="lazy" decoding="async" style="width: 100%; height: auto;" src="https://www.sqlbi.com/wp-content/uploads/timeline-dax-ai-2023-2026.svg" alt="Timeline of what SQLBI published about writing DAX with AI from March 2023 to September 2026, with our assessment by period: not ready until early 2026, promising from February 2026, productive from August 2026" width="1600" height="610" /></a></p>
<p><em>What we published about writing DAX with AI, 2023 to 2026, and our assessment by period. The details and the links are in the table at the end of the post.</em></p>
<h2><strong>What we said, and why we said it</strong></h2>
<p><img loading="lazy" decoding="async" class="nozoom" style="float: left; margin: 0 10px 10px 0; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/icon-hourglass.png" alt="Hourglass" width="150" height="150" /></p>
<p>In March 2023, we published an unplugged video where we <a href="https://www.sqlbi.com/tv/writing-dax-with-chatgpt-4-unplugged-50/">wrote DAX measures with ChatGPT-4</a>. A reader asked how ChatGPT could produce good DAX if most DAX on the internet is inaccurate, and my answer was that it wouldn't. In May 2024, we <a href="https://www.sqlbi.com/tv/writing-dax-with-chatgpt-4o-unplugged-58/">repeated the test with ChatGPT-4o</a>. The result was interesting, but not ready for prime time.</p>
<p>The reason was never opposition to AI. I would not go back two years and write .NET code without Copilot. However, in 2023 and 2024, and for most of 2025, you couldn't think of writing DAX with AI without being able to read it well, which implies you could also write it. We did not want to suggest AI to write DAX: telling someone who cannot understand DAX (as many people were at the time) to blindly trust DAX measures generated by AI would have been a risk we did not want to promote.</p>
<p>In August 2025, we ran an experiment we did not publish: We tried to use AI to generate exercises for our courses. It gave ideas, it wrote good descriptive text, and the exercises were correct in their English. But they were also wrong. They repeated the example just shown instead of testing whether the student had understood the concept in a different scenario – and in several cases, they told the student to do the wrong thing.</p>
<p>That experiment fairly summarizes 2025. Productivity was low, given the time and skill required to get something usable. My logic is simple: if a tool saves me time, it works; if it doesn't, it doesn't make me more productive, it isn't ready, and I can wait for another version.</p>
<h2><strong>What changed in 2026</strong></h2>
<p><img loading="lazy" decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/icon-student-robot.png" alt="Robot wearing a graduation cap" width="150" height="150" /></p>
<p>In February 2026, I saw the first sign. I sent Alberto a chat where a model asked for an example to explain a DAX concept and got it badly wrong. When I pointed out the error, it corrected it, corrected a second problem I hadn't noticed, and explained why. The correction showed that the AI had started to reason over the model rather than over the syntax. I like to say that AI failed the exam, but it was a very promising student.</p>
<p>Since Opus 4.8, we have seen big improvements, and the current generation of models (Opus 5, Fable, Sol, Astra, Grok 4.6, and others) reaches a level of DAX-writing quality we can no longer ignore. In my experience, two capabilities have changed. The first is generalization: the ability to abstract a concept and apply it to a different problem, which wasn't there two years ago and wasn't this refined six months ago. The second is the ability to work for one or two hours on a task without going off track. The sentence, "AI only repeats what it has read," could have been true in 2024, but it is definitely not true anymore. The latest models write DAX at a level above most of the students who leave our classroom courses. Not always, not for every problem, but the productivity improvement is definitely here.</p>
<p>Recently, we used AI to produce the exercises for the video courses, the task that had failed in August 2025. This time, <strong>we designed every exercise and let the model execute it; we reviewed everything before publishing</strong>. The result: more exercises, clearer descriptions, in less time. When I <a href="https://www.sqlbi.com/blog/marco/2026/07/08/generative-ai-guidelines-at-sqlbi-2026-update/">updated our generative AI guidelines</a> on July 8, 2026, I wrote that we used AI for DAX analysis and "rarely in DAX coding". Two months later, that sentence was already outdated, which shows how fast things change.</p>
<h2><strong>Why we did not say this earlier</strong></h2>
<p><img loading="lazy" decoding="async" class="nozoom" style="float: left; margin: 0 10px 10px 0; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/icon-u-turn.png" alt="U-turn road sign" width="150" height="150" /></p>
<p>I expect the objection: "A year ago you said AI was not ready for DAX, and now you sell courses about it." All true, but there are no contradictions between this and our other statements. To make life easier for those looking for these statements, I included a table at the end of the article.</p>
<p>When there was a lot of hype and the tools did not work, we said it was too early. Now the tools are not perfect, but they are at a level where, if you check what they are doing, they save a lot of time. We kept applying the same rules for evaluating technologies, and the tools evolved. In July 2025, we said we would discuss AI to write DAX only when we saw clear, measurable benefits: we see them now.</p>
<p>Another reason is specific to training. A generic LLM course in 2025 would have filled a classroom, and it would have been obsolete within six months. <strong>It was too early for us to produce content about it</strong>. I don't know whether September 2026 is early, late, or on time, but it is the moment when we have something to teach that we expect to still be valid in a year or more.</p>
<p>I know, it looks like we made a U-turn instead of simply applying our judgment about the maturity of the tools. However, I stand by that, which was preferable than telling people to write DAX with AI too early. Today, it's not always 100% correct, and performance isn't always ideal. But the productivity gains are significant enough to justify its use. <strong>You should still be able to read DAX</strong> and validate the measures, but you probably don't have to be an advanced DAX expert as if you had to write all the code. That makes a big difference.</p>
<h2><strong>What works today</strong></h2>
<p>In August 2026, we published two articles that illustrate the capabilities of AI in DAX. The first is <a href="https://www.sqlbi.com/articles/creating-dax-functions-with-ai-to-remove-duplicated-code/">creating DAX functions with AI to remove duplicated code</a>: when two measures share most of their code, in any language you move the common part into a function. With user-defined functions, you can do that in DAX too, and AI can write the function and replace the corresponding code in existing measures. Without AI, you can do this with some automated tools, but they stop at the first small difference between the two functions, whereas AI can handle those differences by moving parameters and adjusting the existing code to fit the new function.</p>
<p>When I write a measure, I have to look for the edge cases where the business rule could fail. This takes a lot of time, which is why almost nobody creates such tests. The AI connected to the semantic model finds the cases and writes the DAX queries in about ten minutes while I do something else. I have to check the expected values, because the tests must be validated at some point. In this case, the time saved doesn't shorten DAX writing, but it makes it possible to do validation work that was usually ignored.</p>
<p>These are two examples where we see <strong>clear and measurable benefits</strong>. When writing DAX code for an existing model, you have to be careful. When AI generates the model, the outcome is usually better. We are at the point where it can save time and money, depending on your skills. I can give many examples where writing a DAX formula takes less time than writing the prompt for it, at least for someone who knows DAX. At the same time, if I write complex calculations or transformations in DAX, it can save me time typing the formula if I review it carefully later. For someone who doesn't know DAX well, the quality of the DAX it produces usually addresses the question (if the requirements are clear), even if the code isn't ideal or bulletproof from a performance standpoint.</p>
<h2><strong>What still requires</strong><strong> your attention</strong></h2>
<p><strong>Nothing is perfect</strong>, neither are humans. We still have to pay attention to the prompt, the context, and, in particular, the model used in this work. There is a huge difference between the latest frontier models and what was released a year ago or more. Evaluating specific models is a topic for another article, and it will probably only be valid for a few weeks. So I prefer to focus on what you need to watch out for.</p>
<p>Set the goal, define the requirements clearly, identify edge cases, create tests, and make your model and measures more robust than what you would have done in the past: not because it was unnecessary, but because it was too expensive. We now have tools at our disposal that save us enough time to then focus on improving the quality of the solution we create. We will write more about this in future articles, and we have started incorporating these best practices into our new courses.</p>
<h2><strong>Conclusions</strong></h2>
<p><img loading="lazy" decoding="async" class="nozoom" style="float: right; margin: 0 0 10px 10px; border: none !important;" src="https://www.sqlbi.com/wp-content/uploads/icon-keep-thinking.png" alt="Light bulb with a gear inside" width="150" height="150" /></p>
<p>We have used the same rule for many years: <strong>we use a tool when it saves time in our work</strong>, we say what does not work as long as it does not work, and we say it works when it starts to work. When it comes to writing DAX with AI, that moment came in 2026: using AI today for DAX development is productive, and we can recommend it.</p>
<p>I also have another recommendation: Use AI to improve your productivity, but <strong>do not stop thinking</strong>. Your added value is in the corrections you apply to the output, and in DAX, they are probably more than the 5 to 10% that apply to other languages.</p>
<p>There has never been a better time to <strong>Enjoy DAX!</strong></p>
<p>&nbsp;</p>
<h2><strong>Timeline: what we published, and when</strong></h2>
<table>
<thead>
<tr>
<td><strong>When</strong></td>
<td><strong>What</strong></td>
<td><strong>What we said</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td>March<br />
2023</td>
<td><a href="https://www.sqlbi.com/tv/writing-dax-with-chatgpt-4-unplugged-50/">Writing DAX with ChatGPT-4 (Unplugged #50)</a></td>
<td>A reader asked how ChatGPT could produce good DAX if most DAX on the internet is inaccurate. My reply: "Indeed, it will not."</td>
</tr>
<tr>
<td>May<br />
2024</td>
<td><a href="https://www.sqlbi.com/tv/writing-dax-with-chatgpt-4o-unplugged-58/">Writing DAX with ChatGPT-4o (Unplugged #58)</a></td>
<td>The same test, one year later, with a similar outcome.</td>
</tr>
<tr>
<td>November<br />
2024</td>
<td><a href="https://www.sqlbi.com/tv/compare-dax-optimizer-vs-chatgpt-vs-copilot-for-power-bi/">Compare DAX Optimizer vs ChatGPT vs Copilot for Power BI</a></td>
<td>Feature-by-feature comparison; deterministic results as one of the criteria.</td>
</tr>
<tr>
<td>July<br />
2025</td>
<td><a href="https://www.sqlbi.com/blog/marco/2025/07/28/a-few-thoughts-about-newsletter-300-and-ai/">A few thoughts about newsletter #300 and AI</a></td>
<td>"AI speeds up specific tasks dramatically, but the full end-to-end time savings aren't always as impressive as the initial prototypes suggest."</td>
</tr>
<tr>
<td>July<br />
2026</td>
<td><a href="https://www.sqlbi.com/blog/marco/2026/07/08/generative-ai-guidelines-at-sqlbi-2026-update/">Generative AI guidelines at SQLBI (2026 update)</a></td>
<td>"We can use AI for DAX analysis and rarely in DAX coding." And: "If you stop thinking, you become disposable."</td>
</tr>
<tr>
<td>August<br />
2026</td>
<td><a href="https://www.sqlbi.com/articles/creating-dax-functions-with-ai-to-remove-duplicated-code/">Creating DAX functions with AI to remove duplicated code</a></td>
<td>"AI is a great tool to author DAX code. Clearly, the code needs to be validated thoroughly before putting it in production."</td>
</tr>
<tr>
<td>August<br />
2026</td>
<td><a href="https://www.sqlbi.com/tv/testing-dax-measures-by-using-ai/">Testing DAX measures by using AI</a></td>
<td>"Use AI to explore the model and generate the repetitive code; keep the definition of what is correct behavior under human control."</td>
</tr>
<tr>
<td>September<br />
2026</td>
<td><a href="https://www.sqlbi.com/p/ai-for-power-bi-intro-video-course/">AI for Power BI: Intro</a><br />
<a href="https://www.sqlbi.com/p/dax-with-ai-essentials-video-course/">DAX with AI: Essentials</a><br />
<a href="https://www.sqlbi.com/p/dax-with-ai-scenarios-video-course/">DAX with AI: Scenarios</a></td>
<td>Launch three new courses about using AI with Power BI and DAX.</td>
</tr>
</tbody>
</table>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/blog/marco/2026/09/22/where-we-stand-on-ai-and-dax-in-2026/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The hidden complexity of a daily average in DAX</title>
		<link>https://www.sqlbi.com/articles/the-hidden-complexity-of-a-daily-average-in-dax/</link>
					<comments>https://www.sqlbi.com/articles/the-hidden-complexity-of-a-daily-average-in-dax/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Mon, 21 Sep 2026 20:00:08 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Data modeling]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=903719</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0308-head.png" class="webfeedsFeaturedVisual" /></figure>A simple daily average masks a level of complexity that may not be immediately apparent. In this article, we use AI to create a daily average, and then to analyze several edge-case scenarios to build a sound calculation. Computing an&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0308-head.png" class="webfeedsFeaturedVisual" /></figure><p>A simple daily average masks a level of complexity that may not be immediately apparent. In this article, we use AI to create a daily average, and then to analyze several edge-case scenarios to build a sound calculation.<span id="more-903719"></span></p>
<p>Computing an average daily sales amount is straightforward: you should iterate over the dates, compute sales for each day, and average the results. An AI assistant can generate DAX code that works in just a few seconds; whether it computes the number you need is a different question.</p>
<p>In this article, we ask AI to generate every measure, function, and validation query. We start with a simple average and test it against more demanding scenarios. Our job is to explain the business requirements, challenge the proposed code, and verify the results. Each test reveals a missing detail from the original request.</p>
<p>The prompts below show a conversation with an AI agent. They describe how to get the DAX code from the AI. They are not a verbatim transcript: a different agent might produce different expressions.</p>
<p>The goal is not to test the assistant or demonstrate complex DAX code. The goal is to show that AI makes it easier to write code. In doing so, it leaves more time for humans to focus on inspecting border cases, refining the formula, and producing better calculations. The very same scenario would be challenging for a human, too.</p>
<p>We start with the following prompt:</p>
<blockquote><p>Create a measure Average Daily Sales (Selling Days) that computes the average daily sales amount by iterating over Date and computing [Sales Amount]</p></blockquote>
<p>A plausible answer is the following, although your execution result may differ:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Average Daily Sales (Selling Days) =
AVERAGEX ( &#039;Date&#039;, &#x5B;Sales Amount] )
</pre>
<p>The <em>Date</em> table contains one row per day. DAX evaluates <em>Sales Amount</em> for each date visible in the filter context, as it iterates the <em>Date</em> table reference. We can ask the assistant to iterate over the <em>Date[Date]</em> column:</p>
<blockquote><p>Rewrite the measure to iterate over the distinct values of Date[Date], instead of the entire Date table. Keep the existing blank-handling behavior and explain whether this change affects the denominator in this model.</p></blockquote>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Average Daily Sales (Selling Days) =
AVERAGEX ( VALUES ( &#039;Date&#039;&#x5B;Date] ), &#x5B;Sales Amount] )
</pre>
<p>The measure now works on a single-column table, and it seems a bit more efficient. However, both versions have the same issue: AVERAGEX excludes blank results from the average but considers zero as a relevant value. The two different table expressions produce the same behavior and result.</p>
<p>The following figure shows a simple average over five rows, with the two possible calculations. AVERAGEX performs the calculation on the left, and it ignores blanks.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0308.01.01-Blank-changes-the-denominator.svg" width="800" /></p>
<p>To make the issue more evident, look at the following matrix, where we filtered one color (Brown) and expanded January 2024.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0308-A.png" width="650" /></p>
<p>The value shown for January 2024 is the same as 01/19/2024, the only day with sales.</p>
<p><em>Product</em> filters <em>Sales</em>; therefore, it filters its results, but it does not filter <em>Date</em> through the single-direction relationships. January shows 31 days, but Sales Amount is blank for 30 of them. We can ask AI for a query that makes the denominator visible:</p>
<blockquote><p>Show me a DAX query for January 2024 that compares all product colors with the color Brown. Return the color, sales amount, the number of dates with a nonblank Sales Amount, and the average over those dates. Use the Sales Amount measure and query-scoped definitions for any additional measures. Do not change the model. Explain why a date without sales is excluded from this average.</p></blockquote>
<p>The query generated should return a result very similar to the following one.</p>
<table width="100%">
<tbody>
<tr>
<td width="106"><strong>January 2024</strong></td>
<td width="141"><strong>Sales Amount</strong></td>
<td width="141"><strong>Days with sales</strong></td>
<td width="141"><strong>Average Daily Sales (Selling Days)</strong></td>
</tr>
<tr>
<td width="106">All colors</td>
<td width="141">188,419.28</td>
<td width="141">27</td>
<td width="141">6,978.49</td>
</tr>
<tr>
<td width="106">Brown</td>
<td width="141">8,454.80</td>
<td width="141">1</td>
<td width="141">8,454.80</td>
</tr>
</tbody>
</table>
<p>In January 2024, total sales are 188,419.28 across 27 days. The first measure returns 6,978.49. January has 31 days, but four have a blank <em>Sales Amount</em> and are excluded from the denominator. For Brown products, things are even worse: only one day has sales. In both cases, the number of considered days is less than 31.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0308.01.02-Less-sales-can-produce-a-larger-average.svg" width="800" /></p>
<p>There is no arithmetic error here. The measure computes average sales over days with a non-blank <em>Sales Amount</em>. For this sample, these are the days with sales. If this is the intended business definition, the measure is correct. However, if we want average sales per calendar day, the Brown result should be 8,454.80 divided by 31, or 272.74: the denominator should include days without sales.</p>
<p>To obtain the latter definition, we include an additional requirement in the prompt:</p>
<blockquote><p>
Generate a revised measure named Average Daily Sales (Calendar Days). Divide the total Sales Amount by the number of visible rows in Date, which has one row per day. A product filter must change the amount without removing days from the denominator. Use safe division, preserve a blank amount for now, and do not yet adjust for the beginning or end of the available history.</p></blockquote>
<p>The generated measure does not have an iterator anymore:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Average Daily Sales (Calendar Days) =
DIVIDE ( &#x5B;Sales Amount], COUNTROWS ( &#039;Date&#039; ) )
</pre>
<p>Because <em>Date</em> contains one row per day, COUNTROWS returns the number of visible days. A filter on <em>Product</em> changes the numerator and not the denominator, because <em>Date</em> does not receive filters from other tables. The result now corresponds to the more refined requirements.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0308-B.png" width="700" /></p>
<p>Another option would have been to replace blanks with zero inside AVERAGEX. For a period with sales, that would solve the denominator problem, even though the measure generated would be slower.</p>
<p>However, neither approach tells us whether all visible dates should participate in the calculation, in case the available calendar goes beyond the date range for which we have transactions.</p>
<p>To evaluate that condition, we ask AI to inspect the dates with the following prompt:</p>
<blockquote><p>
Generate a DAX query returning one row with the number of Date rows, the minimum and maximum Date[Date], the number of Sales rows, the minimum and maximum Sales[Order Date], the distinct count of order dates, and Sales Amount. Also count blank order dates and distinct order dates missing from Date. Query the model without modifying it. Report the date ranges without assuming that the first and last transaction prove data completeness.</p></blockquote>
<p>The query shows that the calendar runs from January 1, 2022 through December 31, 2026. The first transaction is on May 21, 2022, and the last is on March 21, 2026.</p>
<table>
<tbody>
<tr>
<td><strong>Field</strong></td>
<td><strong>Result</strong></td>
</tr>
<tr>
<td><strong>Date Rows</strong></td>
<td>1,826</td>
</tr>
<tr>
<td><strong>First Calendar Date</strong></td>
<td>January 1, 2022</td>
</tr>
<tr>
<td><strong>Last Calendar Date</strong></td>
<td>December 31, 2026</td>
</tr>
<tr>
<td><strong>Sales Rows</strong></td>
<td>3,996</td>
</tr>
<tr>
<td><strong>First Order Date</strong></td>
<td>May 21, 2022</td>
</tr>
<tr>
<td><strong>Last Order Date</strong></td>
<td>March 21, 2026</td>
</tr>
<tr>
<td><strong>Distinct Order Dates</strong></td>
<td>880</td>
</tr>
<tr>
<td><strong>Sales Amount</strong></td>
<td>4,373,105.53</td>
</tr>
<tr>
<td><strong>Blank Order Date Rows</strong></td>
<td>0</td>
</tr>
<tr>
<td><strong>Distinct Order Dates Missing from Date</strong></td>
<td>0</td>
</tr>
</tbody>
</table>
<p>The calendar in the <em>Date</em> table has months without transactions. Even if we reduce the calendar from May 2022 to March 2026, May 2022 (the first month with sales) contains 11 observed days, and March 2026 (the last month with sales) contains 21. Dividing sales by 31 days in either month understates the average.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0308.01.03-Incomplete-months-need-a-smaller-day-count.svg" width="800" /></p>
<p>The problem occurs at both ends of the available history. It also affects totals that include dates before or after that history, in case we did not reduce the calendar.</p>
<p>Notice the assumption we just introduced. The first transaction does not prove that data collection started on that date, and the last transaction does not prove that later dates are unavailable. It is possible that there were no sales on other days.</p>
<p>For the following example, we use the first and last transaction dates as the boundaries of a continuous observation period. We consider every date within that period available, including dates without transactions. In a production model, it is better to use exact data-availability dates when transaction dates cannot be used reliably.</p>
<p>Before improving the formula, we can ask AI to challenge the definition:</p>
<blockquote><p>
Review this average daily sales calculation before proposing another formula. Find small examples that distinguish days without sales from days outside the available data. Include product filters, incomplete first and last months, an empty period, nonconsecutive date selections, and totals. State the expected denominator and identify any business rule that the data alone cannot establish.</p></blockquote>
<p>This is a useful role for AI. Instead of asking only for implementation, we also ask it to find cases that might disprove it. A proposed test becomes useful when we can state its expected result independently and then execute it.</p>
<p>The AI result is a table containing several edge case scenarios that must be carefully inspected and covered by our new rule.</p>
<table>
<tbody>
<tr>
<td><strong>Test</strong></td>
<td><strong>Small example</strong></td>
<td><strong>Expected denominator</strong></td>
</tr>
<tr>
<td><strong>Day without sales</strong></td>
<td>Select May 22, 2022, which has no transactions but lies inside coverage.</td>
<td>1 day</td>
</tr>
<tr>
<td><strong>Day outside coverage</strong></td>
<td>Select May 20, 2022, before assumed coverage starts.</td>
<td>0 days</td>
</tr>
<tr>
<td><strong>Product filter</strong></td>
<td>Select January 2024 and Brown products. Brown has sales on one day, but the entire month is observed.</td>
<td>31 days, not 1</td>
</tr>
<tr>
<td><strong>Incomplete first month</strong></td>
<td>Select May 2022. Count May 21–31, including days without sales.</td>
<td>11 days, not 31</td>
</tr>
<tr>
<td><strong>Incomplete last month</strong></td>
<td>Select March 2026. Count March 1–21, even though its first transaction is March 3.</td>
<td>21 days, not 31</td>
</tr>
<tr>
<td><strong>Observed period without product sales</strong></td>
<td>Select March 2026 and Green products. Green has no sales that month.</td>
<td>21 days</td>
</tr>
<tr>
<td><strong>Period entirely outside coverage</strong></td>
<td>Select April 2026. No selected dates fall inside the coverage.</td>
<td>0 days</td>
</tr>
<tr>
<td><strong>Empty date selection</strong></td>
<td>Apply a filter that selects no dates.</td>
<td>0 days</td>
</tr>
<tr>
<td><strong>Nonconsecutive dates</strong></td>
<td>Select May 21, 22, and 28, 2022. Include the blank sales result on May 22, but exclude unselected dates between them.</td>
<td>3 days, not 8</td>
</tr>
<tr>
<td><strong>Nonconsecutive months</strong></td>
<td>Select January and March 2024. February is not selected.</td>
<td>62 days, not 91</td>
</tr>
<tr>
<td><strong>Total across unequal periods</strong></td>
<td>Select February and March 2026 together. February contributes 28 days; March contributes 21.</td>
<td>49 days</td>
</tr>
</tbody>
</table>
<p>After analyzing the scenarios, we end up with the following requirements for our average:</p>
<ul>
<li>Count the selected dates that fall within the observation period.</li>
<li>Include days without sales within that period.</li>
<li>Use the same observation period for every product, customer, and store selection.</li>
<li>Return zero when there are days observed but no sales for the current selection.</li>
<li>Return blank when there are no observed days selected.</li>
</ul>
<p>The difference between zero and blank matters: zero means we observed a time period and found no sales; blank means we want to ignore that period for the average.</p>
<p>A possible mistake would be to compute the first and last sale after removing only the <em>Date</em> filter, because it is incompatible with our requirements. With that approach, a product selection can move the boundaries. In our sample file, the last sale of a Green product is February 12, 2026, whereas other products have sales through March 21, 2026. Selecting Green should not make March unavailable. However, for our requirements, the March average is zero over 21 days observed.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0308.01.04-Zero-and-blank-answer-different-questions.svg" width="800" /></p>
<p>For the same reason, we must not use each month’s first and last transaction as that month’s boundaries. March 2026 has its first transaction on March 3, but March 1 and March 2 are inside the overall observation period, so they must be counted.</p>
<p>We now have enough information to create the request for the complete measure:</p>
<blockquote><p>
Generate a measure named Average Daily Sales using these rules:<br />
- Define one inclusive observation period from the first to the last Sales[Order Date], ignoring all ordinary report filters when finding those boundaries.<br />
- Count only currently visible, nonblank Date[Date] values inside that period.<br />
- Preserve nonconsecutive selections.<br />
- Compute Sales Amount over exactly those dates while preserving the other report filters.<br />
- Include dates without sales in the denominator.<br />
- Return zero for an observed selection without sales, and blank if there are no observed dates or no boundary dates.<br />
- Use variables to make the steps readable.</p></blockquote>
<p>The resulting code is considerably longer than the first expression we obtained at the beginning of the article:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Average Daily Sales =
VAR FirstObservedDate =
    CALCULATE ( MIN ( Sales&#x5B;Order Date] ), REMOVEFILTERS () )
VAR LastObservedDate =
    CALCULATE ( MAX ( Sales&#x5B;Order Date] ), REMOVEFILTERS () )
VAR ObservedDates =
    FILTER (
        VALUES ( &#039;Date&#039;&#x5B;Date] ),
        NOT ISBLANK ( &#039;Date&#039;&#x5B;Date] )
            &amp;&amp; &#039;Date&#039;&#x5B;Date] &gt;= FirstObservedDate
            &amp;&amp; &#039;Date&#039;&#x5B;Date] &lt;= LastObservedDate
    )
VAR NumberOfDays = COUNTROWS ( ObservedDates )
VAR Amount =
    CALCULATE ( &#x5B;Sales Amount], KEEPFILTERS ( ObservedDates ) )
RETURN
    IF (
        NOT ISBLANK ( FirstObservedDate )
            &amp;&amp; NOT ISBLANK ( LastObservedDate )
            &amp;&amp; NumberOfDays &gt; 0,
        DIVIDE ( COALESCE ( Amount, 0 ), NumberOfDays )
    )
</pre>
<p><em>FirstObservedDate</em> and <em>LastObservedDate</em> are evaluated after removing any report filters. Therefore, a filter on products or months in a matrix row does not move the boundaries. REMOVEFILTERS does not bypass row-level security: the interval is shared within the data visible to the current security context.</p>
<p><em>ObservedDates</em> starts from <em>VALUES ( 'Date'[Date] )</em>, which contains the dates visible in the current filter context. FILTER keeps only those dates within the observation period and excludes a possible blank member.</p>
<p>The code considers only the selected dates. For example, if the user selects January and March, the denominator must not include February. If it counted the elapsed days between the first and last selected date, it would include February, which the user could have excluded. The same principle applies to a selection of individual days or weekdays.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0308.01.05-Count-selected-dates-inside-the-observation-period.svg" width="800" /></p>
<p>The <em>Average Daily Sales</em> measure then counts <em>ObservedDates</em> and evaluates <em>Sales Amount</em> over the same set. KEEPFILTERS intersects this set with the current context. Filters applied to <em>Product</em>, <em>Customer</em>, and <em>Store</em> continue to affect the amount.</p>
<p>Finally, the measure returns a result only when the boundaries exist and at least one observed day is selected. COALESCE explicitly returns zero for an observed period without sales.</p>
<p>At this point, the AI has generated considerably more DAX than the original request had suggested. If we need the same rule in several measures, we can ask AI to place the logic in a DAX user-defined function (UDF). The following prompt must be executed in the same LLM session we previously used, so it implicitly references the measure <em>Average Daily Sales</em> which the AI created before:</p>
<blockquote><p>Generate a DAX user-defined function named Contoso.AveragePerObservedDay that encapsulates the observed-date selection, day counting, amount evaluation, and zero-versus-blank policy of the revised measure. Accept three parameters: an amount expression, the first observed date, and the last observed date. The caller must supply the boundaries.</p></blockquote>
<p>The result is a reusable function that encapsulates the complex logic and can be reused in different measures:</p>
<div class="dax-code-title">Function</div>
<pre class="brush: dax; snippet: Function; notranslate">
Contoso.AveragePerObservedDay =
    (
        AmountExpression : SCALAR EXPR,
        FirstObservedDate : SCALAR VAL,
        LastObservedDate : SCALAR VAL
    ) =&gt;
        VAR ObservedDates =
            FILTER (
                VALUES ( &#039;Date&#039;&#x5B;Date] ),
                NOT ISBLANK ( &#039;Date&#039;&#x5B;Date] )
                    &amp;&amp; &#039;Date&#039;&#x5B;Date] &gt;= FirstObservedDate
                    &amp;&amp; &#039;Date&#039;&#x5B;Date] &lt;= LastObservedDate
            )
        VAR NumberOfDays = COUNTROWS ( ObservedDates )
        VAR Amount =
            CALCULATE ( AmountExpression, KEEPFILTERS ( ObservedDates ) )
        RETURN
            IF (
                NOT ISBLANK ( FirstObservedDate )
                    &amp;&amp; NOT ISBLANK ( LastObservedDate )
                    &amp;&amp; NumberOfDays &gt; 0,
                DIVIDE ( COALESCE ( Amount, 0 ), NumberOfDays )
            )
</pre>
<p>The function is intentionally tied to the <em>Date</em> table that must exist in the model. It accepts <em>AmountExpression</em> as the expression to compute within the two observation boundaries specified in the following arguments. The caller decides where the boundaries come from, while the function implements the selection, counting, and empty-result rules.</p>
<p>Once the function is in place, we ask the AI to generate the measure that invokes the function:</p>
<blockquote><p>Generate a measure named Average Daily Sales (Function) that calls Contoso.AveragePerObservedDay with Sales Amount. Preserve the business behavior of Average Daily Sales.</p></blockquote>
<p>The measure generated should be very close to the following one:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Average Daily Sales (Function) =
Contoso.AveragePerObservedDay (
    &#x5B;Sales Amount],
    CALCULATE ( MIN ( Sales&#x5B;Order Date] ), REMOVEFILTERS () ),
    CALCULATE ( MAX ( Sales&#x5B;Order Date] ), REMOVEFILTERS () )
)
</pre>
<p>Other additive amounts using the same date relationship, observation period, and zero policy can reuse the function. A balance or a distinct customer count would need a separate analysis: dividing an aggregate by a day count is not generally equivalent to averaging its daily values.</p>
<h2>Conclusions</h2>
<p>Although it looks like a simple task, computing an average hides a lot of complexity. This is true for simple calculations, but it is also true (and harder) for more complex calculations. When you define a calculation, you always need to ask yourself how the calculation will behave in border-case scenarios, typically at the beginning or at the end of a time period, at the subtotal and total levels, with different selections, or with blank values in some of the columns or partial calculations.</p>
<p>This is where AI shines, because we can delegate several tasks: perform deeper analysis, try different versions of the code, and find examples that may prove the measure correct or disprove it, showing that some fixes are still needed.</p>
<p>Before the advent of AI, BI professionals spent much of their time writing and debugging DAX code. Today, AI can reduce that time, helping us improve the quality and soundness of measures and calculations.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/the-hidden-complexity-of-a-daily-average-in-dax/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Marco Russo]]></dc:creator>
	</item>
		<item>
		<title>Writing DAX at the correct granularity</title>
		<link>https://www.sqlbi.com/tv/writing-dax-at-the-correct-granularity/</link>
					<comments>https://www.sqlbi.com/tv/writing-dax-at-the-correct-granularity/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Tue, 08 Sep 2026 10:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">http://www.sqlbi.com/?post_type=video&#038;p=903191</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/hIdtNrp047M/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>A DAX calculation can produce convincing values at the detail level and fail at the total. The problem is often that the business rule was evaluated at the wrong granularity. This video introduces four grains, or levels of granularity, to&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/hIdtNrp047M/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>A DAX calculation can produce convincing values at the detail level and fail at the total. The problem is often that the business rule was evaluated at the wrong granularity. This video introduces four grains, or levels of granularity, to identify before writing your DAX formula.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/writing-dax-at-the-correct-granularity/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Writing DAX at the correct granularity</title>
		<link>https://www.sqlbi.com/articles/writing-dax-at-the-correct-granularity/</link>
					<comments>https://www.sqlbi.com/articles/writing-dax-at-the-correct-granularity/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Mon, 07 Sep 2026 20:00:23 +0000</pubDate>
				<category><![CDATA[Data Modeling]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[Data modeling]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=902997</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0307-1.png" class="webfeedsFeaturedVisual" /></figure>A DAX calculation can produce convincing values at the detail level and still fail at the total. The problem is often not the total itself: the business rule was evaluated at the wrong granularity. This article introduces four grains, or&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0307-1.png" class="webfeedsFeaturedVisual" /></figure><p>A DAX calculation can produce convincing values at the detail level and still fail at the total. The problem is often not the total itself: the business rule was evaluated at the wrong granularity. This article introduces four grains, or levels of granularity, that should be identified before writing your DAX formula.<br />
<span id="more-902997"></span><br />
DAX code is often short. Understanding the question that the code must answer may be much harder.</p>
<p>Consider a calculation that multiplies a quantity by a rate. The formula appears simple, yet it is correct only if the quantity and the rate are evaluated while the rate has a clear meaning. If you perform the calculation after combining different rates, DAX must aggregate the rates somehow: AVERAGE, MIN, or MAX can return a number. However, returning a number does not make that number meaningful.</p>
<p>The principle to remember is the following:</p>
<blockquote><p>Evaluate the business rule at the lowest grain where all its inputs have one unambiguous meaning; aggregate only afterward.</p></blockquote>
<p>There are four grains involved in applying this principle:</p>
<ul>
<li>The source-table grain.</li>
<li>The business-rule grain.</li>
<li>The iteration or evaluation grain.</li>
<li>The requested output grain.</li>
</ul>
<p>These grains can be the same; in that case, the code is simple to write. The interesting problems arise when they differ. To showcase the scenario, we use a very simple model about producing lemonade.</p>
<h2>Introducing the lemonade model</h2>
<p>The sample model describes lemonade production. It contains two tables joined by a regular one-to-many relationship.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0307-1.png" alt="" width="600" /></p>
<p>Recipe contains one row for each recipe. Ingredient rates are properties of a recipe; they are not additive values, and as such, they cannot be aggregated.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0307-2.png" alt="" width="260" /></p>
<p>Batch contains one row for each production batch, and each batch, expressed in liters produced, follows a recipe.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0307-3.png" alt="" width="200" /></p>
<p>Water is additive. Therefore, the <em>Total Water</em> is straightforward, and it is already visible in the report:</p>
<div class="dax-code-title">Measure in Batch table</div>
<pre class="brush: dax; snippet: Measure; table: Batch; notranslate">
Total Water = SUM ( Batch&#x5B;Water Liters] )
</pre>
<p>However, the business question we want to answer is: “How many sugar spoons and how many liters of lemon juice should we allocate to prepare the three batches?”</p>
<p>The ingredient requirements are business rules:</p>
<ul>
<li>Sugar spoons are water liters multiplied by the sugar rate of the recipe.</li>
<li>Lemon juice liters are water liters multiplied by the lemon percentage of the recipe.</li>
</ul>
<p>The calculations are easy for an individual batch. For example, B01 uses 10 liters of water and the Sweet recipe, so it requires 30 spoons of sugar and 2.5 liters of lemon juice. Difficulty appears when multiple recipes are aggregated.</p>
<p>The following measures look reasonable at first sight. <em>Total Water</em> computes the total water, whereas the two percentages need to be aggregated, and AVERAGE may seem like a good idea:</p>
<div class="dax-code-title">Measure in Batch table</div>
<pre class="brush: dax; snippet: Measure; table: Batch; notranslate">
Wrong Sugar = &#x5B;Total Water] * AVERAGE ( Recipe&#x5B;Sugar Spoons per Liter] )
</pre>
<div class="dax-code-title">Measure in Batch table</div>
<pre class="brush: dax; snippet: Measure; table: Batch; notranslate">
Wrong Lemon = &#x5B;Total Water] * AVERAGE ( Recipe&#x5B;Lemon Juice % of Water] )
</pre>
<p>Both measures produce the expected value when the report shows one recipe in each row, but the total is clearly wrong. The value is correct at both the batch and recipe levels. Above the recipe level, it is not correct.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0307-4.png" alt="" width="350" /></p>
<p>At the total level, <em>Wrong Sugar</em> computes 14 liters multiplied by the unweighted average of 1 and 3 spoons per liter. The result is 28. <em>Wrong Lemon</em> computes 14 multiplied by the average of 10% and 25%, returning 2.45 liters.</p>
<p>Neither calculation represents the production plan. The batches contain 12 liters of Sweet lemonade and only 2 liters of Classic lemonade. A simple average gives both recipes the same weight, producing an incorrect result.</p>
<p>By default, Power BI does not sum the visible rows. A measure is evaluated independently in every cell. In the total cell, the requested output contains both recipes, and the formula explicitly asks DAX to average their rates. DAX answers that question correctly; it is the question that is wrong, because it does not consider the different granularities at play.</p>
<p>The four grains identify where the mistake occurs.</p>
<table width="100%">
<tbody>
<tr>
<td width="30%"><strong>Grain</strong></td>
<td width="35%"><strong>Question</strong></td>
<td width="34%"><strong>Lemonade example</strong></td>
</tr>
<tr>
<td width="30%">Source-table grain</td>
<td width="35%">What does one row in each table represent?</td>
<td width="34%">One production batch in Batch; one recipe in Recipe</td>
</tr>
<tr>
<td width="30%">Business-rule grain</td>
<td width="35%">At what grain do all inputs to the rule have one meaning?</td>
<td width="34%">Recipe, because one recipe determines one sugar rate and one lemon juice percentage</td>
</tr>
<tr>
<td width="30%">Iteration or evaluation grain</td>
<td width="35%">What rows does DAX evaluate before aggregating?</td>
<td width="34%">Batch rows, recipe rows, or one row for the entire filter context</td>
</tr>
<tr>
<td width="30%">Requested output grain</td>
<td width="35%">What grouping does the report request for the current cell?</td>
<td width="34%">Batch, recipe, or total</td>
</tr>
</tbody>
</table>
<p>The source grain is a property of the data, not of the DAX code. In this model, Batch and Recipe have different grains. The model works because every batch identifies its recipe through a relationship.</p>
<p>The business-rule grain is the level at which the rule can be evaluated without inventing an aggregation for any of its inputs. In the current model, you can first sum water by recipe because the ingredient rate is constant within each recipe.</p>
<p>This produces the following intermediate result.</p>
<table width="100%">
<tbody>
<tr>
<td width="16%"><strong>Recipe</strong></td>
<td width="16%"><strong>Water liters</strong></td>
<td width="15%"><strong>Sugar rate</strong></td>
<td width="18%"><strong>Sugar spoons</strong></td>
<td width="16%"><strong>Lemon rate</strong></td>
<td width="16%"><strong>Lemon liters</strong></td>
</tr>
<tr>
<td width="16%">Classic</td>
<td width="16%">2</td>
<td width="15%">1.00</td>
<td width="18%">2</td>
<td width="16%">10%</td>
<td width="16%">0.20</td>
</tr>
<tr>
<td width="16%">Sweet</td>
<td width="16%">12</td>
<td width="15%">3.00</td>
<td width="18%">36</td>
<td width="16%">25%</td>
<td width="16%">3.00</td>
</tr>
</tbody>
</table>
<p>Only after applying the rule to each row of this table is it safe to aggregate. The correct totals are 38 sugar spoons and 3.20 liters of lemon juice.</p>
<p>Evaluating at a finer grain is also safe, as we show with the next measure. In our example, computing the rule once for every batch produces the same result because the rate is constant for all batches of the same recipe.<br />
However, evaluating below the necessary grain can perform more work than required. A useful operational interpretation of the central rule is therefore:</p>
<blockquote><p>Never evaluate above the business-rule grain. A finer grain can be correct; the coarsest grain that still preserves an unambiguous meaning is usually more efficient.</p></blockquote>
<p>The DAX expression defines the evaluation and the granularity: the table passed to the SUMX iterator declares the grain of the calculation. For example, the following measure evaluates the sugar rule at the Batch granularity. It multiplies the water liters in each <em>Batch</em> row by the number of sugar spoons per liter defined in the corresponding recipe:</p>
<div class="dax-code-title">Measure in Batch table</div>
<pre class="brush: dax; snippet: Measure; table: Batch; notranslate">
Sugar Spoons at batch grain =
SUMX (
    Batch,
    Batch&#x5B;Water Liters] *
        RELATED ( Recipe&#x5B;Sugar Spoons per Liter] )
)
</pre>
<p>This formula is correct. However, you can perform the same calculation at the business-rule grain.</p>
<div class="dax-code-title">Measure in Batch table</div>
<pre class="brush: dax; snippet: Measure; table: Batch; notranslate">
Sugar Spoons =
SUMX (
    SUMMARIZE (
        Batch,
        Recipe&#x5B;Recipe],
        Recipe&#x5B;Sugar Spoons per Liter]
    ),
    &#x5B;Total Water] * Recipe&#x5B;Sugar Spoons per Liter]
)
</pre>
<p>SUMMARIZE builds one row for each recipe visible in the current filter context. SUMX iterates those rows. <em>Total Water</em> invokes the context transition because it is a measure, so it returns the water for the current recipe. The rate comes from the recipe itself, which is the same iterated row. Finally, SUMX aggregates the recipe results, only after the rule has been applied.</p>
<p>The lemon calculation follows the same structure:</p>
<div class="dax-code-title">Measure in Batch table</div>
<pre class="brush: dax; snippet: Measure; table: Batch; notranslate">
Total Lemon =
SUMX (
    SUMMARIZE (
        Batch,
        Recipe&#x5B;Recipe],
        Recipe&#x5B;Lemon Juice % of Water]
    ),
    &#x5B;Total Water] * Recipe&#x5B;Lemon Juice % of Water]
)
</pre>
<p>In this specific calculation, grouping only by <em>Recipe[Lemon Juice % of Water]</em> would also be correct and more efficient. Recipes with the same percentage can be combined because the percentage is the only non-additive input the rule uses. However, grouping by recipe as well can be simpler for an initial implementation, and it is easier to change if the rule later needs other recipe properties. Similarly, <em>Sugar Spoons</em> could aggregate by <em>Recipe[Sugar Spoons per Liter]</em>, using a single multiplication for all recipes with the same number of sugar spoons per liter.</p>
<p>The source-grain and business-grain versions return the same values at the recipe rows and at the total. Both formulas evaluate the multiplication before combining rows with different rates.</p>
<p>The query generated for the report determines the requested output grain. A matrix can request a value for each batch, each recipe, or the entire production plan. It can also change after a user drills down or adds a field to the visual.</p>
<p>A robust measure does not rely on the output grain to produce correct results. In order to make the rule unambiguous, the measure enforces its own evaluation grain internally:</p>
<ul>
<li>On a recipe row, the iterator sees one recipe.</li>
<li>At the grand total, the iterator sees both recipes and sums two results.</li>
<li>If the visual does not display Recipe at all, the measure still evaluates the rule by recipe.</li>
</ul>
<p>This is why you should not fix a total by blindly iterating the rows currently visible in a visual. The visual grain is a presentation choice. The business-rule grain belongs in the measure and should remain valid when the visual changes.</p>
<h2>Recognizing the same problem in budgeting</h2>
<p>Budgeting scenarios are a larger version of the lemonade example. Actual sales might exist by transaction, product, and day, while a budget is defined by product category and month. The source tables have different grains, the requested report can use yet another grain, and an allocation rule introduces its own grain.</p>
<p>There are only two correct choices when a report requests detail below the budget grain:</p>
<ul>
<li>Do not display the budget at unsupported detail.</li>
<li>Define an explicit allocation rule that creates that detail.</li>
</ul>
<p>Repeating a category budget for every product is not allocation. It duplicates the value. Similarly, computing one allocation factor after categories or periods have already been combined evaluates the rule at a grain above its valid level.</p>
<p>The <a href="https://www.daxpatterns.com/budget/">Budget pattern</a> makes the business choices explicit and computes prior-year sales at the forecast grain before allocating the forecast. The article, <a href="https://www.sqlbi.com/articles/budget-and-other-data-at-different-granularities-in-powerpivot/">Budget and Other Data at Different Granularities in PowerPivot</a> illustrates the related modeling problem with daily sales and monthly budgets. In both cases, the complexity comes from creating meaning across grains: the DAX formula in the model measure is the final representation of those choices.</p>
<p>The four-grain framework scales to these scenarios:</p>
<table width="100%">
<tbody>
<tr>
<td width="32%"><strong>Grain</strong></td>
<td width="67%"><strong>Typical budgeting example</strong></td>
</tr>
<tr>
<td width="32%">Source-table grain</td>
<td width="67%">Sales by transaction and day; budget by category and month</td>
</tr>
<tr>
<td width="32%">Business-rule grain</td>
<td width="67%">The category-month or other governed allocation group</td>
</tr>
<tr>
<td width="32%">Iteration or evaluation grain</td>
<td width="67%">The groups over which allocation factors are computed and applied</td>
</tr>
<tr>
<td width="32%">Requested output grain</td>
<td width="67%">Product, day, territory, subtotal, or grand total requested by the report</td>
</tr>
</tbody>
</table>
<p>The developer must decide whether the requested output is supported directly, needs an allocation, or should return blank. You cannot delegate that decision to AVERAGE or the total row of a matrix.</p>
<h2>A checklist for grain-aware DAX</h2>
<p>Before writing a measure, answer these questions:</p>
<ol>
<li>What does one row mean in every source table used by the calculation?</li>
<li>Which keys make every rate, threshold, percentage, status, or other rule input unambiguous?</li>
<li>Which inputs are additive before the rule is applied, and which are not?</li>
<li>What virtual table should an iterator enumerate to express the business-rule grain?</li>
<li>Is the chosen evaluation grain independent of the fields currently displayed in the visual?</li>
<li>Has any upstream transformation aggregated away a key required by the rule?</li>
<li>What should happen when the report requests detail below the grain supported by the data?</li>
<li>Can the result be verified by manually computing a few business-grain rows and aggregating them?</li>
</ol>
<p>The last test can be very effective. Do not start by checking whether the grand total equals the visible rows. First, build the small intermediate table at the business-rule grain, validate each row, and only then validate its aggregation.</p>
<h2>Conclusion</h2>
<p>The hardest part of many DAX calculations is deciding where to evaluate the business rule. The source grain describes the available data. The business-rule grain describes where the rule has meaning. The iteration grain describes what the DAX code actually does. The requested output grain describes what the report asks for. Correct results require these four grains to be compatible, not necessarily identical.</p>
<p>The lemonade model is a simple example to show what could go wrong, because it has only two recipes and three batches. In a real model, the same mistake can be hidden behind thousands of products, changing rates, allocations, and several dimensions.</p>
<p>The rule of thumb is to evaluate the business rule at the lowest grain where all its inputs have one unambiguous meaning, and aggregate only afterward.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/writing-dax-at-the-correct-granularity/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Marco Russo]]></dc:creator>
	</item>
		<item>
		<title>Matrix Totals - The Whiteboard #13</title>
		<link>https://www.sqlbi.com/tv/matrix-totals-the-whiteboard-13/</link>
					<comments>https://www.sqlbi.com/tv/matrix-totals-the-whiteboard-13/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Wed, 02 Sep 2026 12:44:43 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<guid isPermaLink="false">http://www.sqlbi.com/?post_type=video&#038;p=902818</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/jbGEXZ85Nr0/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>Let's talk about matrix totals in this episode of The Whiteboard! Special guest: the SQLBI Whiteboard! Learn abstract DAX concepts in a more interactive way with "The Whiteboard" series. Read more: https://www.sqlbi.com/blog/marco/2022/07/14/the-whiteboard-video-series-on-sqlbi-youtube-channel/ #thewhiteboard]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/jbGEXZ85Nr0/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>Let's talk about matrix totals in this episode of The Whiteboard!<br />
Special guest: the SQLBI Whiteboard!</p>
<p>Learn abstract DAX concepts in a more interactive way with "The Whiteboard" series.<br />
Read more: https://www.sqlbi.com/blog/marco/2022/07/14/the-whiteboard-video-series-on-sqlbi-youtube-channel/</p>
<p>#thewhiteboard</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/matrix-totals-the-whiteboard-13/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQLBI Whiteboard</title>
		<link>https://www.sqlbi.com/tools/sqlbi-whiteboard/</link>
					<comments>https://www.sqlbi.com/tools/sqlbi-whiteboard/#respond</comments>
		
		<dc:creator><![CDATA[SQLBI]]></dc:creator>
		<pubDate>Thu, 27 Aug 2026 11:29:59 +0000</pubDate>
				<guid isPermaLink="false">https://www.sqlbi.com/?post_type=tool&#038;p=902955</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/SQLBI.Whiteboard.svg" class="webfeedsFeaturedVisual" /></figure>SQLBI Whiteboard is a free, open-source whiteboard for Windows 11 designed for teaching DAX, SQL, and data modeling, with pen ink, live application capture, and syntax-highlighted code on the same canvas. Pen-first ink — Low-latency, pressure-aware strokes with palm rejection,&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/SQLBI.Whiteboard.svg" class="webfeedsFeaturedVisual" /></figure><p>SQLBI Whiteboard is a free, open-source whiteboard for Windows 11 designed for teaching DAX, SQL, and data modeling, with pen ink, live application capture, and syntax-highlighted code on the same canvas.<br />
<span id="more-902955"></span></p>
<ul dir="ltr">
<li><strong>Pen-first ink</strong> — Low-latency, pressure-aware strokes with palm rejection, rear-eraser support, and a barrel-button laser pointer, alongside full touch and mouse support on an unbounded canvas.</li>
<li><strong>Live application capture</strong> — Embed a live view of any running window or display on the board — a Power BI report, SSMS, anything — then freeze it and draw over it.</li>
<li><strong>DAX and SQL snippets</strong> — Paste code into containers with live syntax highlighting, and format DAX or T-SQL with one key.</li>
<li><strong>Boards are files</strong> — Documents are local <code>.wboard</code> files with no account and no cloud service, and Markdown-based <code>.wimport</code> recipes build a prepared board from a text file.</li>
</ul>
<p>SQLBI Whiteboard is a standalone application rather than a collaboration service: there is no shared canvas, no tenant, and no sign-in. It is designed for the room, the projector, the recorded lesson, and the pen — the way we teach.</p>
<p>Download it from the Microsoft Store, or as an installer or portable ZIP from GitHub, where the source code is available under the MIT license. Documentation, guide, and FAQ are at <a href="https://whiteboard.sqlbi.com">whiteboard.sqlbi.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tools/sqlbi-whiteboard/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Testing DAX measures by using AI</title>
		<link>https://www.sqlbi.com/tv/testing-dax-measures-by-using-ai/</link>
					<comments>https://www.sqlbi.com/tv/testing-dax-measures-by-using-ai/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Tue, 25 Aug 2026 10:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">http://www.sqlbi.com/?post_type=video&#038;p=902139</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/qYQpl5Hjdk0/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>How to use AI to identify relevant test cases in a semantic model and create repeatable DAX tests for a measure.]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/qYQpl5Hjdk0/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>How to use AI to identify relevant test cases in a semantic model and create repeatable DAX tests for a measure.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/testing-dax-measures-by-using-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Testing DAX measures by using AI</title>
		<link>https://www.sqlbi.com/articles/testing-dax-measures-by-using-ai/</link>
					<comments>https://www.sqlbi.com/articles/testing-dax-measures-by-using-ai/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Mon, 24 Aug 2026 20:00:44 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[semantic model]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=902664</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0306-cover.png" class="webfeedsFeaturedVisual" /></figure>This article describes how to use AI to identify relevant test cases in a semantic model and create repeatable DAX tests for a measure. A DAX measure is correct only when it produces the expected result in every situation of&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0306-cover.png" class="webfeedsFeaturedVisual" /></figure><p>This article describes how to use AI to identify relevant test cases in a semantic model and create repeatable DAX tests for a measure.<br />
<span id="more-902664"></span></p>
<p>A DAX measure is correct only when it produces the expected result in every situation of filter context and available data. A value being correct in a report for a particular product or customer does not prove that the measure works for other selections. This matters when the measure implements business logic that depends on the active filters.</p>
<p>We usually validate this logic by creating report pages that isolate a few customers and transactions. This is useful during development because we can see the data and we can reason about the result. However, manual validation is difficult to repeat after every change. It is also easy to forget a filter combination that previously exposed a problem.</p>
<p>AI can help with the repetitive part of this work. Once connected to the semantic model, the AI assistant can explore the data, find representative cases, and generate DAX queries that reproduce the required filter contexts. The expected results still require human validation. The role of AI is to find and automate the cases, not to define the business requirement.</p>
<h2>Understanding the measure to test</h2>
<p>We start from the <a href="https://www.daxpatterns.com/new-and-returning-customers/">New and returning customers</a> pattern and, in particular, from the <strong>Dynamic relative</strong> implementation of the <em># New Customers</em> measure. The pattern takes into account all the report filters. For example, if the report filters the Audio category, a customer is considered new on the first date when they purchase an Audio product. An earlier purchase in another category does not make the customer exist for the Audio category.</p>
<p>The same rule applies to brands. If the filter contains Contoso and Northwind Traders, the two brands form one selection. The customer is new on their first purchase date across the union of those brands. The measure must not compute a separate first purchase date for each brand.</p>
<p>This behavior makes the measure a good candidate for regression testing. A modification can preserve the result of a simple case while changing how the measure handles a category filter or a multiple-brand selection. Therefore, testing only a straightforward positive result is not enough.</p>
<h2>Identifying four types of tests</h2>
<p>We want tests that can detect both incorrect inclusions and incorrect exclusions. For this reason, we manually identify four types of cases before asking AI to automate them:</p>
<ul>
<li>A <strong>positive test</strong>checks that a qualifying customer is counted. This is the simplest valid case and it confirms that the main path of the calculation works.</li>
<li>A <strong>negative test</strong>checks that a customer without a qualifying purchase in the selected context is not counted. This detects filters that are ignored or incorrectly removed.</li>
<li>A <strong>prevent false positive test</strong>uses a case that looks valid under a narrower filter but is invalid under the filter being tested. This detects a measure that counts too many customers.</li>
<li>A <strong>prevent false negative test</strong>uses a valid case with an earlier purchase outside the current selection. This detects a measure that counts too few customers because it evaluates the first purchase over the wrong set of products.</li>
</ul>
<p>We manually created the following report pages, which isolate one case for each purpose. Read the details of each example to understand the type of tests implemented, which are intended to evaluate possible regressions in case of changes to the measure. You can skip the details of each case if you just want to see how to automate this process.</p>
<h3>Testing a positive case</h3>
<p>Customer 362, Cindy Ramos, purchased Audio products from both Contoso and Northwind Traders on April 9, 2007. This is the first purchase date in the selected two-brand Audio context. Therefore, <em># New Customers</em> must return 1.</p>
<p>The report also shows later purchases when all brands and categories are visible. Those later transactions do not affect the expected result on April 9, 2007.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0306-01.png" width="800" /></p>
<p>This test confirms that a customer with a qualifying first purchase is included. However, it does not prove that the measure excludes transactions outside the selection.</p>
<h3>Testing a negative case</h3>
<p>Customer 11317, Deanna Sara, made a purchase on July 9, 2007. That transaction was for Fabrikam in Cameras and camcorders, so it is outside the selected Contoso and Northwind Traders Audio context. The expected value of <em># New Customers</em> for that date and selection is 0.</p>
<p>The same customer first purchased Audio from Northwind Traders on July 23, 2007. The report returns 1 on that later date under the two-brand Audio filter, but it must not return 1 on July 9.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0306-02.png" width="800" /></p>
<p>This test detects a measure that removes or ignores the category and brand filters while finding the first purchase.</p>
<h3>Preventing a false positive</h3>
<p>The same customer provides a more subtle case. Deanna Sara bought Audio from Northwind Traders on July 23, 2007, and from Contoso on August 14, 2007. If the report selects only Contoso, the customer is new on August 14 because that is her first Contoso Audio purchase.</p>
<p>The expected result changes when the report selects both Contoso and Northwind Traders. The first purchase in that union occurred on July 23. Therefore, the customer is not new on August 14, and # New Customers must return 0.<br />
<img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0306-03.png" width="800" /></p>
<p>This case detects an implementation that evaluates the first purchase separately for every selected brand. This implementation could pass the positive and negative tests. However, it still counts the same customer as new more than once within a multiple-brand selection.</p>
<h3>Preventing a false negative</h3>
<p>Customer 175, Nicholas Robinson, made a purchase on January 18, 2007, outside the selected Audio context. The first purchase in the Contoso and Northwind Traders Audio selection occurred on October 27, 2007. Consequently, # New Customers must return 1 on October 27.</p>
<p><img decoding="async" src="https://www.sqlbi.com/wp-content/uploads/C0306-04.png" width="800" /></p>
<p>This case detects a measure that uses the first purchase across all products. That behavior would be correct for a dynamic absolute calculation, but it is incorrect for the dynamic relative measure we are testing.</p>
<h2>Asking AI to create the tests</h2>
<p>Manually finding these cases requires repeated filtering and inspection of transaction histories. We can automate the discovery and generation process by connecting an AI assistant to Power BI Desktop through the <a href="https://learn.microsoft.com/en-us/power-bi/developer/mcp/">Power BI Modeling MCP server</a>. The local server lets the assistant inspect the semantic model and execute or validate DAX queries against it.</p>
<p>We used the following prompt:</p>
<blockquote><p>I want to create tests for the # New Customers measure. It is dynamic, which takes into account all the filters in the report for the calculation. Therefore, if the report filters one category (Audio, for example), a customer is reported as new the first time they buy a product of the Audio category. Find cases for one and two brands selected that show positive, negative, and prevent false positive and false negative. Create the DAX queries to validate the test. The query should return one or more row with the test name, the status, and a description of the test result (with an explanation of the issue found). We'll assign each query to a function and run one or more tests together by using UNION of their results.</p></blockquote>
<p>The prompt provides the semantic rule, the dimensions that must vary, the four test purposes, and the required output contract. This information is important. A generic request to test the measure would leave the assistant free to choose cases that do not exercise the relevant filter behavior.</p>
<p>The assistant inspected the model and generated eight tests: four for a single selected brand and four for a two-brand selection. We manually verified the selected transactions before keeping their expected values. This step prevents a circular test in which the measure under test also determines the expected result.</p>
<h2>Organizing tests with DAX functions</h2>
<p>The generated query uses <a href="https://learn.microsoft.com/en-us/dax/best-practices/dax-user-defined-functions">DAX user-defined functions</a> to keep every test independent and give every result the same shape. DAX user-defined functions (UDF) can be defined and evaluated in DAX query view by using the FUNCTION keyword in a DEFINE block. They require compatibility level 1702 or higher and are generally available in Power BI Desktop and the Power BI service starting from the June 2026 release. A common TestResult function compares the actual and expected values and returns one row with the test name, status, and description.</p>
<p>Each test function applies filters for one customer, category, brand selection, and date. TREATAS reproduces the filter context of the report, whereas COALESCE converts a blank result to zero when the customer must not be counted.</p>
<p>The following extract shows the common result function and the two-brand false-positive test:</p>
<div class="dax-code-title">Function</div>
<pre class="brush: dax; snippet: Function; notranslate">
// Creates the standard one-row result returned by every test.
TestResult = (
    testName : STRING,
    actualValue : INT64,
    expectedValue : INT64,
    passDescription : STRING,
    failureExplanation : STRING
) =&gt;
    ROW (
        &quot;Test name&quot;, testName,
        &quot;Status&quot;, IF ( actualValue = expectedValue, &quot;PASS&quot;, &quot;FAIL&quot; ),
        &quot;Description&quot;,
            IF (
                actualValue = expectedValue,
                passDescription,
                failureExplanation
                    &amp; &quot; Expected &quot; &amp; FORMAT ( expectedValue, &quot;0&quot; )
                    &amp; &quot;, got &quot; &amp; FORMAT ( actualValue, &quot;0&quot; ) &amp; &quot;.&quot;
            )
    )
</pre>
<div class="dax-code-title">Function</div>
<pre class="brush: dax; snippet: Function; notranslate">
// Guards against calculating the first purchase separately for each brand.
Test_NewCustomers_2Brands_NoFalsePositive = () =&gt;
    VAR Actual =
        COALESCE (
            CALCULATE (
                &#x5B;# New Customers],
                TREATAS ( { 11317 }, Customer&#x5B;CustomerKey] ),
                TREATAS ( { &quot;Audio&quot; }, Product&#x5B;Category] ),
                TREATAS (
                    { &quot;Contoso&quot;, &quot;Northwind Traders&quot; },
                    Product&#x5B;Brand]
                ),
                TREATAS ( { DATE ( 2007, 8, 14 ) }, &#039;Date&#039;&#x5B;Date] )
            ),
            0
        )
    RETURN
        TestResult (
            &quot;2 brands - prevent false positive&quot;,
            Actual,
            0,
            &quot;Customer 11317 is not counted because the first purchase &quot;
                &amp; &quot;in the selected union was on 2007-07-23.&quot;,
            &quot;The first date was evaluated per brand instead of across &quot;
                &amp; &quot;the selected brand union.&quot;
        )
</pre>
<p>The final EVALUATE statement combines the selected functions with UNION. We can add or remove function calls to run the complete suite or only the tests related to a specific change:</p>
<div class="dax-code-title">Function</div>
<pre class="brush: dax; snippet: Function; notranslate">
EVALUATE
UNION (
    Test_NewCustomers_1Brand_Positive (),
    Test_NewCustomers_1Brand_Negative (),
    Test_NewCustomers_1Brand_NoFalsePositive (),
    Test_NewCustomers_1Brand_NoFalseNegative (),
    Test_NewCustomers_2Brands_Positive (),
    Test_NewCustomers_2Brands_Negative (),
    Test_NewCustomers_2Brands_NoFalsePositive (),
    Test_NewCustomers_2Brands_NoFalseNegative ()
)
</pre>
<p>The sample Power BI file you can download below, contains the helper function and all eight test functions.</p>
<h2>Reading the test results</h2>
<p>Running the query against the original measure produces one row for each test. All eight tests return PASS.</p>
<table>
<thead>
<tr>
<td><strong>Test name</strong></td>
<td><strong>Status</strong></td>
<td><strong>Validated behavior</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td>1 brand - positive</td>
<td>PASS</td>
<td>Customer 362 is counted on the first Contoso Audio purchase date.</td>
</tr>
<tr>
<td>1 brand - negative</td>
<td>PASS</td>
<td>Customer 11317 is not counted on a date with only a Northwind Traders Audio purchase.</td>
</tr>
<tr>
<td>1 brand - prevent false positive</td>
<td>PASS</td>
<td>Customer 4626 is not counted on a repeat Contoso Audio purchase.</td>
</tr>
<tr>
<td>1 brand - prevent false negative</td>
<td>PASS</td>
<td>Customer 175 is counted despite an earlier purchase outside Contoso Audio.</td>
</tr>
<tr>
<td>2 brands - positive</td>
<td>PASS</td>
<td>Customer 362 is counted on the first purchase date in the selected brand union.</td>
</tr>
<tr>
<td>2 brands - negative</td>
<td>PASS</td>
<td>Customer 11317 is not counted for a purchase outside both selected Audio brands.</td>
</tr>
<tr>
<td>2 brands - prevent false positive</td>
<td>PASS</td>
<td>The later Contoso purchase is not treated as an initial purchase.</td>
</tr>
<tr>
<td>2 brands - prevent false negative</td>
<td>PASS</td>
<td>An earlier purchase outside the two-brand Audio selection does not suppress the valid result.</td>
</tr>
</tbody>
</table>
<p>A failing row reports the expected and actual values and includes an explanation of the likely issue. Therefore, the query provides the first piece of information required to investigate a regression when it detects one.</p>
<h2>Keeping the tests useful</h2>
<p>The test query is deterministic after we select the customers, dates, filters, and expected values. The AI discovery process does not need to be deterministic because it is only used to create the initial suite. Once the tests are reviewed, they become ordinary DAX code that we can store with the project and execute again.</p>
<p>These tests depend on the sample data. If transactions or dimension values change, we must review the cases or run them against a stable test model. To implement tests, we always need controlled input data, regardless of whether we use AI to create these tests.</p>
<p>Moreover, the measure passing all eight tests does not prove that the measure is correct for every possible context. The goal of this article was to provide a more efficient way to create tests, but the completeness of the test suite depends on the calculation implemented and the model complexity that could affect the DAX expression.</p>
<h2>Conclusions</h2>
<p>Testing a DAX measure requires more than comparing a few totals. We must reproduce the filter contexts that define the business rules and include cases that detect both false positives and false negatives.</p>
<p>AI connected to the semantic model can reduce the effort required to find those cases and write the corresponding DAX queries. However, we must verify the expected results independently before accepting the tests. Use AI to explore the model and generate the repetitive code; keep the definition of what is correct behavior under human control.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/testing-dax-measures-by-using-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
	</item>
		<item>
		<title>Creating DAX functions with AI to remove duplicated code</title>
		<link>https://www.sqlbi.com/tv/creating-dax-functions-with-ai-to-remove-duplicated-code/</link>
					<comments>https://www.sqlbi.com/tv/creating-dax-functions-with-ai-to-remove-duplicated-code/#respond</comments>
		
		<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
		<pubDate>Tue, 11 Aug 2026 10:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?post_type=video&#038;p=901936</guid>

					<description><![CDATA[<figure><img src="https://i.ytimg.com/vi/sp8Bx2yL3lw/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure>How to leverage AI to refactor existing DAX code, remove duplicated parts, and centralize the common code in user-defined functions.]]></description>
										<content:encoded><![CDATA[<figure><img src="https://i.ytimg.com/vi/sp8Bx2yL3lw/maxresdefault.jpg" class="webfeedsFeaturedVisual" /></figure><p>How to leverage AI to refactor existing DAX code, remove duplicated parts, and centralize the common code in user-defined functions.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/tv/creating-dax-functions-with-ai-to-remove-duplicated-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating DAX functions with AI to remove duplicated code</title>
		<link>https://www.sqlbi.com/articles/creating-dax-functions-with-ai-to-remove-duplicated-code/</link>
					<comments>https://www.sqlbi.com/articles/creating-dax-functions-with-ai-to-remove-duplicated-code/#respond</comments>
		
		<dc:creator><![CDATA[Marco Russo]]></dc:creator>
		<pubDate>Mon, 10 Aug 2026 20:00:00 +0000</pubDate>
				<category><![CDATA[DAX]]></category>
		<category><![CDATA[Power BI]]></category>
		<category><![CDATA[AI]]></category>
		<guid isPermaLink="false">https://www.sqlbi.com/?p=901861</guid>

					<description><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0302.png" class="webfeedsFeaturedVisual" /></figure>Code written by AI can contain many duplicate parts. User-defined functions are a great tool to simplify complex measures; this article shows how to leverage AI to build better DAX code. AI is getting better and better at generating DAX&#8230;]]></description>
										<content:encoded><![CDATA[<figure><img src="https://www.sqlbi.com/wp-content/uploads/C0302.png" class="webfeedsFeaturedVisual" /></figure><p>Code written by AI can contain many duplicate parts. User-defined functions are a great tool to simplify complex measures; this article shows how to leverage AI to build better DAX code.</p>
<p><span id="more-901861"></span></p>
<p>AI is getting better and better at generating DAX code, and as of today, it is pretty common to see rather complex DAX code that is entirely AI-generated. Sometimes AI-generated code requires refactoring or adjustment to make it more performant or reusable.</p>
<p>In this article, we show the process of first obtaining DAX code that actually works with AI, and then refactoring it to produce a better version. How do we refactor it? With AI, of course. AI can be a great tool if you ask it the right questions.</p>
<p>As an example, we are going to use the <a href="https://www.daxpatterns.com/new-and-returning-customers/">New Customer</a> pattern. The prompt is deliberately simple and somewhat ambiguous, as it does not contain any clarification about what we mean by “new” customer, or how we want to generate the code. However, we are not interested in the algorithm but, rather, in the type of DAX code generated:</p>
<blockquote><p>Create two measures: I want to compute the new customers and then the sales of new customers</p></blockquote>
<p>AI quickly answers with two measures:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
# New Customers = 
VAR FirstVisibleDate =
    MIN ( &#039;Date&#039;&#x5B;Date] )
VAR LastVisibleDate =
    MAX ( &#039;Date&#039;&#x5B;Date] )
VAR CustomersInCurrentPeriod =
    VALUES ( Sales&#x5B;CustomerKey] )
VAR NewCustomers =
    FILTER (
        CustomersInCurrentPeriod,
        VAR CurrentCustomerKey = Sales&#x5B;CustomerKey]
        VAR FirstPurchaseDate =
            CALCULATE (
                MIN ( Sales&#x5B;Order Date] ),
                REMOVEFILTERS (),
                TREATAS ( { CurrentCustomerKey }, Customer&#x5B;CustomerKey] )
            )
        RETURN
            FirstPurchaseDate &gt;= FirstVisibleDate
                &amp;&amp; FirstPurchaseDate &lt;= LastVisibleDate
    )
RETURN
    COUNTROWS ( NewCustomers )
</pre>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Sales New Customers = 
VAR FirstVisibleDate =
    MIN ( &#039;Date&#039;&#x5B;Date] )
VAR LastVisibleDate =
    MAX ( &#039;Date&#039;&#x5B;Date] )
VAR CustomersInCurrentPeriod =
    VALUES ( Sales&#x5B;CustomerKey] )
VAR NewCustomers =
    FILTER (
        CustomersInCurrentPeriod,
        VAR CurrentCustomerKey = Sales&#x5B;CustomerKey]
        VAR FirstPurchaseDate =
            CALCULATE (
                MIN ( Sales&#x5B;Order Date] ),
                REMOVEFILTERS (),
                TREATAS ( { CurrentCustomerKey }, Customer&#x5B;CustomerKey] )
            )
        RETURN
            FirstPurchaseDate &gt;= FirstVisibleDate
                &amp;&amp; FirstPurchaseDate &lt;= LastVisibleDate
    )
RETURN
    CALCULATE (
        &#x5B;Sales Amount],
        KEEPFILTERS (
            TREATAS ( NewCustomers, Customer&#x5B;CustomerKey] )
        )
    )
</pre>
<p>AI being AI, the result is not always the same. However, most of the time it produces a similar algorithm. Despite not being super-duper optimized, this algorithm works fine, and it is not a bad solution for a small/medium data model.</p>
<p>As humans, we quickly notice that most of the code is duplicated. Both measures compute the <em>NewCustomers</em> variable; the first one just counts its rows, whereas the second uses the variable as a table filter in CALCULATE. It is the perfect scenario where designing a user-defined function (UDF) would have been a great solution.</p>
<p>However, because of the final step, creating the function is not entirely obvious. A good DAX developer would solve the scenario immediately. What about AI? Let us test it:</p>
<blockquote><p>Both measures have a very similar logic, apart from the last step. Can you create a function that embeds most of the logic of new customers, so to produce simpler measures and put the DAX code at a common factor in the function?</p></blockquote>
<p>AI decides to create a function for the <em>NewCustomers</em> variable only and, AI being AI, it decides to make the function as <a href="https://www.sqlbi.com/articles/model-dependent-and-model-independent-user-defined-functions-in-dax/">model-independent</a> as possible, by passing the required columns as arguments. This is definitely a very good idea, but it also increases the number of parameters to call the function, unless we create a proxy:</p>
<div class="dax-code-title">Function</div>
<pre class="brush: dax; snippet: Function; notranslate">
NewCustomersSet = (
    customerKey : COLUMNREF,
    orderDate : COLUMNREF,
    dateColumn : COLUMNREF
) =&gt;
    VAR FirstVisibleDate = MIN ( dateColumn )
    VAR LastVisibleDate = MAX ( dateColumn )
    VAR CustomersInCurrentPeriod = VALUES ( customerKey )
    VAR NewCustomers =
        FILTER (
            CustomersInCurrentPeriod,
            VAR CurrentCustomerKey = customerKey
            VAR FirstPurchaseDate =
                CALCULATE (
                    MIN ( orderDate ),
                    REMOVEFILTERS (),
                    TREATAS ( { CurrentCustomerKey }, customerKey )
                )
            RETURN
                FirstPurchaseDate &gt;= FirstVisibleDate
                    &amp;&amp; FirstPurchaseDate &lt;= LastVisibleDate
        )
    RETURN
        NewCustomers
</pre>
<p>Indeed, despite the function being very generic, the measures are still quite complicated:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
# New Customers =
COUNTROWS (
    NewCustomersSet (
        Sales&#x5B;CustomerKey],
        Sales&#x5B;Order Date],
        &#039;Date&#039;&#x5B;Date]
    )
)
</pre>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Sales New Customers =
VAR NewCustomers =
    NewCustomersSet (
        Sales&#x5B;CustomerKey],
        Sales&#x5B;Order Date],
        &#039;Date&#039;&#x5B;Date]
    )
RETURN
    CALCULATE (
        &#x5B;Sales Amount],
        KEEPFILTERS (
            TREATAS ( NewCustomers, Customer&#x5B;CustomerKey] )
        )
    )
</pre>
<p>We want to go one step further by simplifying the measures at the cost of generating a model-dependent UDF:</p>
<blockquote><p>I don't want the function to use so many arguments. Create one function that accepts as its only parameter the formula to compute, and then returns the formula computed for only the new customers.</p></blockquote>
<p>Now that our intentions are clearer, AI produces the desired code:</p>
<div class="dax-code-title">Function</div>
<pre class="brush: dax; snippet: Function; notranslate">
NewCustomers = (
    expression : SCALAR EXPR
) =&gt;
    VAR FirstVisibleDate = MIN ( &#039;Date&#039;&#x5B;Date] )
    VAR LastVisibleDate = MAX ( &#039;Date&#039;&#x5B;Date] )
    VAR CustomersInCurrentPeriod = VALUES ( Sales&#x5B;CustomerKey] )
    VAR NewCustomersSet =
        FILTER (
            CustomersInCurrentPeriod,
            VAR CurrentCustomerKey = Sales&#x5B;CustomerKey]
            VAR FirstPurchaseDate =
                CALCULATE (
                    MIN ( Sales&#x5B;Order Date] ),
                    REMOVEFILTERS (),
                    TREATAS ( { CurrentCustomerKey }, Customer&#x5B;CustomerKey] )
                )
            RETURN
                FirstPurchaseDate &gt;= FirstVisibleDate
                    &amp;&amp; FirstPurchaseDate &lt;= LastVisibleDate
        )
    RETURN
        CALCULATE (
            expression,
            KEEPFILTERS (
                TREATAS ( NewCustomersSet, Customer&#x5B;CustomerKey] )
            )
        )
</pre>
<p>And the two measures are straightforward, as desired:</p>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
# New Customers = 
NewCustomers ( &#x5B;# Customers] )
</pre>
<div class="dax-code-title">Measure in Sales table</div>
<pre class="brush: dax; snippet: Measure; table: Sales; notranslate">
Sales New Customers = 
NewCustomers ( &#x5B;Sales Amount] )
</pre>
<p>There are several non-trivial aspects to note here. First, when asked to refactor the function, AI actually changed the algorithm for <em>NewCustomers</em>, moving from COUNTROWS to CALCULATE with a filter. This is not an easy step at all. Moreover, when we requested simpler code, AI decided to reuse the <em># Customers</em> measure rather than keeping the old COUNTROWS.</p>
<h2>Conclusions</h2>
<p>AI is a great tool to author DAX code. Clearly, the code needs to be validated thoroughly before putting it in production. When using AI, a good practice is to ask exactly for what you want, so the code can be generated in a single pass and be good, straight out of the box.</p>
<p>User-defined functions are a great tool in Power BI to centralize code. When authoring code with AI, never forget to search for opportunities to use UDFs, as AI does not always use them. However, a human who can read and understand DAX can produce good results with minimal effort by using functions.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sqlbi.com/articles/creating-dax-functions-with-ai-to-remove-duplicated-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
				<dc:creator><![CDATA[Alberto Ferrari]]></dc:creator>
	</item>
	</channel>
</rss>
