<?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 syntax - calculate(table) vs filter context transition and return  confusion in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3386601#M127610</link>
    <description>&lt;P&gt;Posting the final working solution(s) for the parent &amp;lt; child model&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run with only mbm changed as per suggestion from Owen&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run with suggested changes to both var queries&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2023 05:11:23 GMT</pubDate>
    <dc:creator>garythomannCoGC</dc:creator>
    <dc:date>2023-08-18T05:11:23Z</dc:date>
    <item>
      <title>dax syntax - calculate(table) vs filter context transition and return  confusion</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3382072#M127441</link>
      <description>&lt;P&gt;Dax query to emulate power bi dashboard report table results.&amp;nbsp; Hierarchical model of parent (pml) &amp;lt; child (mbm) &amp;lt; child (mbpl).&lt;/P&gt;
&lt;P&gt;DaxStudio screenshot below.&amp;nbsp; &amp;nbsp;"VAR pml_id" gives same error as shown.&amp;nbsp; " = 'pml'.[Id] "&amp;nbsp; link is a table so why the same error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Code used above&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;
&lt;LI-CODE lang="markup"&gt;/*  model  pml &amp;lt; mbm &amp;lt; mbpl  */
DEFINE
    TABLE pml =    -- pml.id = 3921
        FILTER (
            'Project Master List',
            'Project Master List'[DIR] = "CO"  &amp;amp;&amp;amp; 
            'Project Master List'[Initiative Name] = "Fleet Business Transformation"
        )

    VAR pml_id =   
        ROW ( 
            "Id", MAX ( 'pml'[Id] )
        )

    TABLE mbm = 
        FILTER (
            'Measure Benefit Master',
            'Measure Benefit Master'[DIR] = "CO" &amp;amp;&amp;amp;
            --'Measure Benefit Master'[PM IDId] = pml_id
            'Measure Benefit Master'[PM IDId] = 'pml'[Id]
        )

EVALUATE 
    VAR dummy = 'DirectorateAbbreviation'
RETURN 
    --dummy
    --pml
    --pml_id
    mbm
&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 05:29:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3382072#M127441</guid>
      <dc:creator>garythomannCoGC</dc:creator>
      <dc:date>2023-08-18T05:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: dax syntax - calculate(table) vs filter context transition and return  confusion</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3382566#M127455</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="350775" data-lia-user-login="garythomannCoGC" class="lia-mention lia-mention-user"&gt;garythomannCoGC&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest doing away with the DEFINE TABLE statements, and just use DEFINE VAR.&lt;/P&gt;
&lt;P&gt;I couldn't see anything in the query that relied on query tables, so table variables should be sufficient.&lt;/P&gt;
&lt;P&gt;Using this method,&amp;nbsp;&lt;STRONG&gt;pml_id&lt;/STRONG&gt; can be defined using MAXX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the below work?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;/*  model  pml &amp;lt; mbm &amp;lt; mbpl  */
DEFINE
    VAR pml =
        -- pml.id = 3921
        FILTER (
            'Project Master List',
            'Project Master List'[DIR] = "CO"
                &amp;amp;&amp;amp; 'Project Master List'[Initiative Name] = "Fleet Business Transformation"
        )
    VAR pml_id =
        MAXX ( pml, 'Product'[Id] )
    VAR mbm =
        FILTER (
            'Measure Benefit Master',
            'Measure Benefit Master'[DIR] = "CO"
                &amp;amp;&amp;amp; 'Measure Benefit Master'[PM IDId] = pml_id
        )

EVALUATE
VAR dummy = 'DirectorateAbbreviation'
RETURN --dummy
    --pml
    --pml_id
    mbm&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 10:16:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3382566#M127455</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-08-16T10:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: dax syntax - calculate(table) vs filter context transition and return  confusion</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3383985#M127497</link>
      <description>&lt;P&gt;Interim question :}&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;A title="DAX why the error when the focus has changed" href="https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-why-the-error-when-the-focus-has-changed/m-p/3383983#M127496" target="_blank" rel="noopener"&gt;DAX why the error when the focus has changed&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 00:13:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3383985#M127497</guid>
      <dc:creator>garythomannCoGC</dc:creator>
      <dc:date>2023-08-17T00:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: dax syntax - calculate(table) vs filter context transition and return  confusion</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3384226#M127505</link>
      <description>&lt;P&gt;Error pointing to need for table usage, there are 4 rows to be connected.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Try as table declarations and same error&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;gt; one can not have nested references&amp;nbsp; &amp;nbsp;&lt;A title="Introducing DEFINE TABLE in DAX queries" href="https://www.sqlbi.com/articles/introducing-define-table-in-dax-queries/" target="_blank" rel="noopener"&gt;Introducing DEFINE TABLE in DAX queries&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;gt; now I understand the preference for variable&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;reducing the query further&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;A title="Defining variables in DAX queries" href="https://www.sqlbi.com/articles/defining-variables-in-dax-queries/" target="_blank" rel="noopener"&gt;Defining variables in DAX queries&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 06:00:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3384226#M127505</guid>
      <dc:creator>garythomannCoGC</dc:creator>
      <dc:date>2023-08-17T06:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: dax syntax - calculate(table) vs filter context transition and return  confusion</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3385201#M127554</link>
      <description>&lt;P&gt;Yes, you've hit the nail on the head: "query tables" created with DEFINE TABLE cannot reference each other!&lt;/P&gt;
&lt;P&gt;But variables can &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if your query has evolved since your last post, but I would possibly suggest something like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EVALUATE
VAR pml_id =
    -- pml.id = 3921
    CALCULATE (
        MAX ( 'Project Master List'[Id] ),
        'Project Master List'[DIR] = "CO",
        'Project Master List'[Initiative Name] = "Fleet Business Transformation"
    )
VAR mbm =
    CALCULATETABLE (
        'Measure Benefit Master',
        'Measure Benefit Master'[DIR] = "CO",
        'Measure Benefit Master'[PM IDId] = pml_id
    )
RETURN
    mbm&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 17 Aug 2023 12:02:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3385201#M127554</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-08-17T12:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: dax syntax - calculate(table) vs filter context transition and return  confusion</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3386456#M127605</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;Thank you.&amp;nbsp; &amp;nbsp;Lots of reading via searching 'dax calculatetable vs filter return value'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="FILTER vs CALCULATETABLE" href="https://community.fabric.microsoft.com/t5/Desktop/FILTER-vs-CALCULATETABLE/m-p/197093" target="_blank" rel="noopener"&gt;FILTER vs CALCULATETABLE&lt;/A&gt;&amp;nbsp; was a good discussion around the difference.&amp;nbsp; '&lt;SPAN&gt;CALCULATETABLE triggers context transition whereas FILTER does not. &amp;nbsp;Andy by itself, FILTER creates a row context whereas CALCULATETABLE does not.'&amp;nbsp; Yet when you look at their defininitions both return tables :}&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 02:16:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3386456#M127605</guid>
      <dc:creator>garythomannCoGC</dc:creator>
      <dc:date>2023-08-18T02:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: dax syntax - calculate(table) vs filter context transition and return  confusion</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3386601#M127610</link>
      <description>&lt;P&gt;Posting the final working solution(s) for the parent &amp;lt; child model&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run with only mbm changed as per suggestion from Owen&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run with suggested changes to both var queries&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 05:11:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/dax-syntax-calculate-table-vs-filter-context-transition-and/m-p/3386601#M127610</guid>
      <dc:creator>garythomannCoGC</dc:creator>
      <dc:date>2023-08-18T05:11:23Z</dc:date>
    </item>
  </channel>
</rss>

