<?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: AverageX over Table Variable in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3075621#M106916</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculate tables are not affected by the filter context while measures do. What is the dax code of [var_date_cur_Mo]?&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 23:15:30 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2023-02-10T23:15:30Z</dc:date>
    <item>
      <title>AverageX over Table Variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3073662#M106784</link>
      <description>&lt;P&gt;Been banging my head against the wall searching Google and the forums for similar concept to this issue with no resolution. I can get the first version to work in DAX Studio but can't seem to get the second version to work in PowerBI because of this error: "&lt;EM&gt;Table variable 'tableone' cannot be used in current context because a base table is expected.&lt;/EM&gt;".&lt;BR /&gt;I'm guessing I need to know more about &lt;U&gt;&lt;STRONG&gt;Data lineage&lt;/STRONG&gt;&lt;/U&gt; to really understand how to get this to work properly.&lt;/P&gt;&lt;P&gt;Any advice on areas I should read-up on to continue my learning journey in addition to a solution on this problem would be greatly appreciated. Thanks in advanced&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;dax studio version&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;DEFINE&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;TABLE TableVar =&lt;BR /&gt;&lt;BR /&gt;FILTER(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ADDCOLUMNS(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; VALUES( dDate[FirstofMonth] ),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "Mo", CALCULATE(DISTINCTCOUNT(fKeywords[SK_index]))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;[Mo] &amp;gt; 0 &amp;amp;&amp;amp; dDate[FirstofMonth] &amp;lt; [var_date_cur_Mo]&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;EVALUATE&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;{ AVERAGE( TableVar[Mo] ) }&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;U&gt;powerbi version&lt;/U&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;MeasureTest =&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR tableone =&lt;BR /&gt;&lt;BR /&gt;FILTER(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ADDCOLUMNS(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; VALUES( dDate[FirstofMonth] ),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "Mo", CALCULATE(DISTINCTCOUNT(fKeywords[SK_index]))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;[Mo] &amp;gt; 0 &amp;amp;&amp;amp; dDate[FirstofMonth] &amp;lt; [var_date_cur_Mo]&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;AVERAGE(tableone[Mo])&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I should add, I know the correct result I should be getting and I don't really understand why I don't get the correct result with something like this where the measure should be running a DISTINCTCOUNT while iterating over each FirstOfMonth from the date column and then applying the average to that entire column:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;AVERAGEX(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; VALUES( dDate[FirstofMonth] ),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CALCULATE(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DISTINCTCOUNT( fKeywords[SK_index] )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 06:20:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3073662#M106784</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-10T06:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: AverageX over Table Variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3073720#M106787</link>
      <description>&lt;P&gt;RETURN&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;AVERAGEX(tableone,[Mo])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 06:38:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3073720#M106787</guid>
      <dc:creator>wdx223_Daniel</dc:creator>
      <dc:date>2023-02-10T06:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: AverageX over Table Variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3074759#M106875</link>
      <description>&lt;P&gt;Photos from the results of using your suggested solution do not match the results of other measures. I do not understand why though&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 14:23:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3074759#M106875</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-10T14:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: AverageX over Table Variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3075621#M106916</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculate tables are not affected by the filter context while measures do. What is the dax code of [var_date_cur_Mo]?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 23:15:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3075621#M106916</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-10T23:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: AverageX over Table Variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3075646#M106919</link>
      <description>&lt;P&gt;var_date_cur_Mo = EOMONTH(TODAY(),-1)+1&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2023 00:00:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3075646#M106919</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-11T00:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: AverageX over Table Variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3075648#M106920</link>
      <description>&lt;P&gt;Thinking b/c DAX studio is still executing the EVALUATE and I'm getting the correct result, I just need to figure out what the issue is with the syntax in PowerBI measure so it will provide correct result of 30,109.71.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2023 00:02:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AverageX-over-Table-Variable/m-p/3075648#M106920</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-11T00:02:56Z</dc:date>
    </item>
  </channel>
</rss>

