<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DAX interpreter BUG!!! in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2688442#M80863</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="268213" data-lia-user-login="Element115" class="lia-mention lia-mention-user"&gt;Element115&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Although variables can be used anywhere, however, their result might not be always the same. Because they are evaluated in the context in which they are written.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please refer to this thread for more details.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://radacad.com/caution-when-using-variables-in-dax-and-power-bi" target="_blank" rel="noopener"&gt;Caution When Using Variables in DAX and Power BI&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Eason&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 02:26:44 GMT</pubDate>
    <dc:creator>v-easonf-msft</dc:creator>
    <dc:date>2022-08-09T02:26:44Z</dc:date>
    <item>
      <title>DAX interpreter BUG!!!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2685027#M80569</link>
      <description>&lt;P&gt;The following (code in red) works when run in the Power Bi Desktop version, but as soon as you replace it by the variable name, which contains the same code, Power BI generates an error.&amp;nbsp; In a nutshell, the column [UnreachableSince] is of data type TEXT containing textual representations of DATETIME values and other non-datetime values (I know and there is nothing I can do about this).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;To intercept the DATETIME values, therefore an IF() is used.&amp;nbsp; It all works fine until you decide to use the variable name in place of the inline code inside the nested IF().&lt;BR /&gt;&lt;BR /&gt;So this OK:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DATEDIFF(DATEVALUE([UnreachableSince]) + TIMEVALUE([UnreachableSince]), [ClosedDT], SECOND)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;But this NOT OK!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DATEDIFF(__unreachable_dt, [ClosedDT], SECOND),&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;Code here (sorry but can't add colors when using Insert/Edit code sample from this editor toolbar):&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;ADDCOLUMNS(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; GROUPBY(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ADDCOLUMNS(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CALCULATETABLE(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SELECTCOLUMNS(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;"DownTime", IF ( [ErrorCategory] == "Unreachable",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VAR &lt;FONT color="#000000"&gt;__unreachable_dt &lt;/FONT&gt;= DATEVALUE([UnreachableSince]) + TIMEVALUE([UnreachableSince])&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VAR &lt;FONT color="#000000"&gt;__unreachable_dt_in_secs&lt;/FONT&gt; = DATEDIFF(__start_date, __unreachable_dt, SECOND) &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RETURN&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IF( __unreachable_dt_in_secs &amp;gt;= 0,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATEDIFF(&lt;FONT face="lucida sans unicode,lucida sans" color="#FF0000"&gt;&lt;STRONG&gt;DATEVALUE([UnreachableSince]) + TIMEVALUE([UnreachableSince]&lt;/STRONG&gt;&lt;/FONT&gt;), [ClosedDT], SECOND),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BLANK() //DATEDIFF([CreationDT], [ClosedDT], SECOND)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DATEDIFF([CreationDT], [ClosedDT], SECOND)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;[AssetName],&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;"DownTime", SUMX(CURRENTGROUP(), [DownTime])&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;"% up", 1 - ([DownTime] / __in_service_time)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="trebuchet ms,geneva" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;So am I imagining things, or isn't this a DAX interpreter bug?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2022 01:36:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2685027#M80569</guid>
      <dc:creator>Element115</dc:creator>
      <dc:date>2022-08-06T01:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: DAX interpreter BUG!!!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2685036#M80570</link>
      <description>&lt;P&gt;PBI Desktop vs = July 2022&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2022 02:22:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2685036#M80570</guid>
      <dc:creator>Element115</dc:creator>
      <dc:date>2022-08-06T02:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: DAX interpreter BUG!!!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2688442#M80863</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="268213" data-lia-user-login="Element115" class="lia-mention lia-mention-user"&gt;Element115&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Although variables can be used anywhere, however, their result might not be always the same. Because they are evaluated in the context in which they are written.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please refer to this thread for more details.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://radacad.com/caution-when-using-variables-in-dax-and-power-bi" target="_blank" rel="noopener"&gt;Caution When Using Variables in DAX and Power BI&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Community Support Team _ Eason&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 02:26:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2688442#M80863</guid>
      <dc:creator>v-easonf-msft</dc:creator>
      <dc:date>2022-08-09T02:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: DAX interpreter BUG!!!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2718126#M82781</link>
      <description>&lt;P&gt;TBH what you are saying makes no sense to me:&amp;nbsp; variables&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;are evaluated in the context in which they are written.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variables should be visible in the scope in which they are declared, period.&amp;nbsp; Are you saying that DAX scoping isn't following what we are used to with all major programming languages out there?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, all my variables are usually declared top level, ie right after the 'MeasureName = ' line.&amp;nbsp; Therefore I would expect this scope to be visible all the way down to the RETURN statement.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Isn't it so?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 19:17:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2718126#M82781</guid>
      <dc:creator>Element115</dc:creator>
      <dc:date>2022-08-22T19:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: DAX interpreter BUG!!!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2718157#M82788</link>
      <description>&lt;P&gt;One more thing... I read RADACAD's explanation, however it does not apply here.&amp;nbsp; Look again carefully at the code I posted:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"DownTime", IF ( [ErrorCategory] == "Unreachable",
                         VAR __unreachable_dt = DATEVALUE([UnreachableSince]) + TIMEVALUE([UnreachableSince])
                         VAR __unreachable_dt_in_secs = DATEDIFF(__start_date, __unreachable_dt, SECOND)
                         RETURN
                               IF( __unreachable_dt_in_secs &amp;gt;= 0,
                                     DATEDIFF(DATEVALUE([UnreachableSince]) + TIMEVALUE([UnreachableSince]), [ClosedDT], SECOND),
                                     BLANK() //DATEDIFF([CreationDT], [ClosedDT], SECOND)
                                ),&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;__unreachable_dt is declared right before the RETURN statement and when referenced in the RETURN block inside de DATEDIFF() inside the IF() as the 2nd parameter, the result is not that the computation is wrong.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;In other words, the block of code is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF( condition,
    VAR __declaration0 = ...
    VAR __declaration1 = ...
    
    RETURN
        IF( __declaration1 &amp;gt;= 0,  // no issues here referencing the second variable 
            DATEDIFF( __declaration0, ... ) // issue here CAN'T FIND THE VARIABLE!!!
...

Is this really as it should be???&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is that the interpreter complains the variable does not exist or is not defined!&amp;nbsp; Two very different things, yes?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 20:29:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2718157#M82788</guid>
      <dc:creator>Element115</dc:creator>
      <dc:date>2022-09-06T20:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: DAX interpreter BUG!!!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2751169#M84888</link>
      <description>&lt;P&gt;Hello, any updates?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 18:17:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-interpreter-BUG/m-p/2751169#M84888</guid>
      <dc:creator>Element115</dc:creator>
      <dc:date>2022-09-06T18:17:40Z</dc:date>
    </item>
  </channel>
</rss>

