<?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: Average over Last 10 Records with Filters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522210#M29716</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp; I'm actually referencing the solution you offered here in my post if you could potentially offer any help.&amp;nbsp;&lt;BR /&gt;In the screenshot below from Power BI - if I had the first 10 records here for Lebron James, I get a total of 614.75 points, divided by 10 records = 61.475 average over the last 10. But the measure is &amp;lt; 1 point off at 62.19 points.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any idea why that may be?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 29 Nov 2020 00:01:28 GMT</pubDate>
    <dc:creator>ZonkyDFS</dc:creator>
    <dc:date>2020-11-29T00:01:28Z</dc:date>
    <item>
      <title>Average over Last 10 Records with Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522204#M29715</link>
      <description>&lt;P&gt;I'm working with a set of basketball data with the following fields:&lt;BR /&gt;Name, PlayerID, Day(This is the date the game was played), FantasyPoints, Games(1 or 0 depending if they played or not)&lt;BR /&gt;&lt;BR /&gt;I'm trying to show at any point in time the average number of points that a player has scored over their last 10 games that they played in. (Excluding games they did not play).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've tried a couple of other DAX solutions from this forum, and I found one that gets somewhat close, but it's off by decimal points.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;AvgL10DKPoints = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR thisdate = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MAX(NBA_Player_Stats[Day])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR Last10Days = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;TOPN(10, FILTER(ALL(NBA_Player_Stats[Day]), NBA_Player_Stats[Day] &amp;lt;= thisdate), NBA_Player_Stats[Day], DESC)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE(AVERAGE(NBA_Player_Stats[FantasyPointsDraftKings]), Last10Days)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 28 Nov 2020 23:51:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522204#M29715</guid>
      <dc:creator>ZonkyDFS</dc:creator>
      <dc:date>2020-11-28T23:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Average over Last 10 Records with Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522210#M29716</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp; I'm actually referencing the solution you offered here in my post if you could potentially offer any help.&amp;nbsp;&lt;BR /&gt;In the screenshot below from Power BI - if I had the first 10 records here for Lebron James, I get a total of 614.75 points, divided by 10 records = 61.475 average over the last 10. But the measure is &amp;lt; 1 point off at 62.19 points.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any idea why that may be?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 00:01:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522210#M29716</guid>
      <dc:creator>ZonkyDFS</dc:creator>
      <dc:date>2020-11-29T00:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Average over Last 10 Records with Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522267#M29723</link>
      <description>&lt;P&gt;Can you share your pbix?&amp;nbsp; When I try your measure with the data you've shown (I OCR'ed it), I get the expected 61.470 for the first one.&amp;nbsp; I suspect you are sometimes including dates not shown.&amp;nbsp; You mentioned the column with 1 or 0 to indicate if they played that day or not.&amp;nbsp; My guess is you are unintentionally including some 0 days (and effectively averaging only 9 or 8 games).&amp;nbsp; You probably need to update the measure to exclude dates with 0 in the Game column.&amp;nbsp; For example, when I changed the TOPN to 8, I get the same number you are seeing, so there are two extra dates without scores in the first one (they don't add in as zeros to the average though).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 04:20:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522267#M29723</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-11-29T04:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Average over Last 10 Records with Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522268#M29724</link>
      <description>&lt;P&gt;I haven't had to share a .PBIX here before, and it doesn't look like I can just drag and drop it in or attach it. I have a filter added to "all pages" that sets a condition of 1 for the Games Played field, but wouldn't the ALL function ignore that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above DAX, how would I modify that TOPN function to include the condition where Games = 1?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 05:00:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522268#M29724</guid>
      <dc:creator>ZonkyDFS</dc:creator>
      <dc:date>2020-11-29T05:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Average over Last 10 Records with Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522571#M29747</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp;PMd you the file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 17:19:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522571#M29747</guid>
      <dc:creator>ZonkyDFS</dc:creator>
      <dc:date>2020-11-29T17:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Average over Last 10 Records with Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522616#M29749</link>
      <description>&lt;P&gt;Here is a measure that uses only the last 10 games in which they played.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Avg.&amp;nbsp;Points&amp;nbsp;Last&amp;nbsp;10&amp;nbsp;Games&amp;nbsp;Played&amp;nbsp;=&lt;BR /&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;VAR&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="Variable" style="color: #49b0af;"&gt;thisdate&lt;/SPAN&gt;&amp;nbsp;=&lt;BR /&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;MAX&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&amp;nbsp;NBA_Player_Stats[Day]&amp;nbsp;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;VAR&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="Variable" style="color: #49b0af;"&gt;Last10Days&lt;/SPAN&gt;&amp;nbsp;=&lt;BR /&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;TOPN&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Number" style="color: #ee7f18;"&gt;10&lt;/SPAN&gt;,&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;CALCULATETABLE&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&amp;nbsp;NBA_Player_Stats[Day]&amp;nbsp;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;)&lt;/SPAN&gt;,&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;ALL&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&amp;nbsp;NBA_Player_Stats[Day]&amp;nbsp;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;)&lt;/SPAN&gt;,&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;NBA_Player_Stats[Day]&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;SPAN class="Variable" style="color: #49b0af;"&gt;thisdate&lt;/SPAN&gt;,&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;NBA_Player_Stats[Games]&amp;nbsp;=&amp;nbsp;&lt;SPAN class="Number" style="color: #ee7f18;"&gt;1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;)&lt;/SPAN&gt;,&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;NBA_Player_Stats[Day],&amp;nbsp;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;DESC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;RETURN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Keyword" style="color: #035aca;"&gt;AVERAGE&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;&amp;nbsp;(&lt;/SPAN&gt;&amp;nbsp;NBA_Player_Stats[FantasyPointsDraftKings]&amp;nbsp;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;)&lt;/SPAN&gt;,&lt;BR /&gt;&lt;SPAN class="indent8"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Variable" style="color: #49b0af;"&gt;Last10Days&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="indent4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Parenthesis" style="color: #808080;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Regards,&lt;/DIV&gt;
&lt;DIV&gt;Pat&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 29 Nov 2020 19:47:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522616#M29749</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-11-29T19:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Average over Last 10 Records with Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522763#M29753</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="273210" data-lia-user-login="ZonkyDFS" class="lia-mention lia-mention-user"&gt;ZonkyDFS&lt;/a&gt;&amp;nbsp;guess your current measure does not exclude the date when one player not played. ie games=0&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 00:58:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-over-Last-10-Records-with-Filters/m-p/1522763#M29753</guid>
      <dc:creator>wdx223_Daniel</dc:creator>
      <dc:date>2020-11-30T00:58:01Z</dc:date>
    </item>
  </channel>
</rss>

