<?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: FIRSTDATE() and internal logic of DAX expressions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FIRSTDATE-and-internal-logic-of-DAX-expressions/m-p/2530080#M70930</link>
    <description>&lt;P&gt;The easiest answer is here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://dax.guide/calculate" target="_blank" rel="noopener"&gt;https://dax.guide/calculate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and here&lt;/P&gt;&lt;P&gt;&lt;A href="https://dax.guide/firstdate" target="_blank" rel="noopener"&gt;https://dax.guide/firstdate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FIRSTDATE is a tricky function because it automatically performs context transition&lt;/STRONG&gt;, even without being wrapped in CALCULATE. This explains why the last thing works but produces a completely wrong answer.&lt;/P&gt;</description>
    <pubDate>Fri, 20 May 2022 17:36:21 GMT</pubDate>
    <dc:creator>daXtreme</dc:creator>
    <dc:date>2022-05-20T17:36:21Z</dc:date>
    <item>
      <title>FIRSTDATE() and internal logic of DAX expressions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FIRSTDATE-and-internal-logic-of-DAX-expressions/m-p/2529981#M70919</link>
      <description>&lt;P&gt;Hello everyone, I'm trying to understand some DAX logic, my first question would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does this expression work correctly:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE( AVERAGE('Table'[Value]), FIRSTDATE('Table'[Period]) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;In the documentation it says&amp;nbsp;that FIRSTDATE returns a table with a single row in it - so how does CALCULATE know how to use it correctly?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Next question - this expression will return an error:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE(&amp;nbsp;AVERAGE('Table'[Value]),&amp;nbsp;'Table'[Period]&amp;nbsp;= FIRSTDATE('Table'[Period]) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;but this will not:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;AVERAGE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'[Value]&lt;/SPAN&gt;&lt;SPAN&gt;),&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'Table'[Period]&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;= FIRSTDATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'[Period]&lt;/SPAN&gt;&lt;SPAN&gt;) ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;altought it will not produce correct results either. Why no error though?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 20 May 2022 17:27:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FIRSTDATE-and-internal-logic-of-DAX-expressions/m-p/2529981#M70919</guid>
      <dc:creator>mbidelski</dc:creator>
      <dc:date>2022-05-20T17:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: FIRSTDATE() and internal logic of DAX expressions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FIRSTDATE-and-internal-logic-of-DAX-expressions/m-p/2530080#M70930</link>
      <description>&lt;P&gt;The easiest answer is here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://dax.guide/calculate" target="_blank" rel="noopener"&gt;https://dax.guide/calculate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and here&lt;/P&gt;&lt;P&gt;&lt;A href="https://dax.guide/firstdate" target="_blank" rel="noopener"&gt;https://dax.guide/firstdate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FIRSTDATE is a tricky function because it automatically performs context transition&lt;/STRONG&gt;, even without being wrapped in CALCULATE. This explains why the last thing works but produces a completely wrong answer.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 17:36:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FIRSTDATE-and-internal-logic-of-DAX-expressions/m-p/2530080#M70930</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-05-20T17:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: FIRSTDATE() and internal logic of DAX expressions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FIRSTDATE-and-internal-logic-of-DAX-expressions/m-p/2535110#M71227</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="221464" data-lia-user-login="mbidelski" class="lia-mention lia-mention-user"&gt;mbidelski&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please learn more about&lt;A href="https://docs.microsoft.com/en-us/dax/firstdate-function-dax" target="_self"&gt;&amp;nbsp;FIRSTDATE&lt;/A&gt;:&amp;nbsp;Returns the first date in the current context for the specified column of dates.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;this expression will return an error:&amp;nbsp;A function 'FIRSTDATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The error is caused by&lt;STRONG&gt; using a TRUE/FALSE expression&lt;/STRONG&gt;, something that evaluates to TRUE or FALSE, to filter the table in a way that CALCULATE or CALCULATETABLE doesn’t support.&amp;nbsp; So the error is saying you can’t use a boolean comparison to filter your table except in very specific circumstances.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;More details :&amp;nbsp;&lt;A href="https://www.sqlgene.com/2019/04/16/dax-error-a-function-xxxx-has-been-used-in-a-true-false-expression-that-is-used-as-a-table-filter-expression-this-is-not-allowed/" target="_self"&gt;DAX error: A function ‘XXXX’ has been used in a True/False expression that is used as a table filter expression. This is not allowed.&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;Why no error though. Please learn more about measure and column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Calculated columns (and tables) are:&lt;/P&gt;
&lt;P&gt;- Evaluated for each row in your table, immediately after you hit 'Enter' to complete the formula&lt;/P&gt;
&lt;P&gt;- Saved back into the model so take up space&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculated Measures are:&lt;/P&gt;
&lt;P&gt;- Evaluated when you use it in a visual, when&amp;nbsp;the visual is rendered&lt;/P&gt;
&lt;P&gt;- Not saved anywhere (well, actually there's a cache in the report layer but it's not part of the file when you hit Save)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally, measures are more useful, but the trade-offs are the performance hit (report runtime vs. pre-processed), storage space, and the type of expressions you can use. For example calculated columns are often used when you want to filter on the result rather than just as a calculated result.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/" target="_self"&gt;calculated columns and measures in dax&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ Polly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 06:39:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FIRSTDATE-and-internal-logic-of-DAX-expressions/m-p/2535110#M71227</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-24T06:39:35Z</dc:date>
    </item>
  </channel>
</rss>

