<?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: Rolling average with filter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629587#M33001</link>
    <description>&lt;P&gt;&lt;A href="https://drive.google.com/drive/folders/16GoTloQOeYLuvgu6eMl6M0LSgKA4iJzj?usp=sharing" target="_blank"&gt;https://drive.google.com/drive/folders/16GoTloQOeYLuvgu6eMl6M0LSgKA4iJzj?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to create calculated column instead of measure?&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jan 2021 16:11:30 GMT</pubDate>
    <dc:creator>arutsjak90</dc:creator>
    <dc:date>2021-01-28T16:11:30Z</dc:date>
    <item>
      <title>Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1628980#M32973</link>
      <description>&lt;P&gt;Hi, I am trying to create 3months back rolling average with filter, becaue it needs to be rolling average per Plant. What I have created (or edited)&amp;nbsp; below.&lt;/P&gt;&lt;P&gt;*T&lt;SPAN&gt;he table I'm working on was created with the Summarize function&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;COGSTotal = SUMMARIZE(COGS,COGS[TotalByPlantKey],COGS[Plant],COGS[FixedDate],"Total COGS",SUM(COGS[ CostOfSale]))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt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t;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;*A circular error appears&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;3MonthsRollingAverage = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR LastDate_ =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LASTDATE ( COGSTotal[FixedDate])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;AVERAGEX ( VALUES (COGSTotal[FixedDate]), CALCULATE ( SUM ( COGSTotal[Total COGS] ) ) ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FILTER (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;COGSTotal,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;COGSTotal[Plant]=EARLIER(COGSTotal[Plant]) &amp;amp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[FixedDate] &amp;lt;= LastDate_ &amp;amp;&amp;amp; [FixedDate] &amp;gt; DATEADD ( LastDate_, -3, MONTH ) ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Jan 2021 13:32:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1628980#M32973</guid>
      <dc:creator>arutsjak90</dc:creator>
      <dc:date>2021-01-28T13:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629193#M32985</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="200455" data-lia-user-login="arutsjak90" class="lia-mention lia-mention-user"&gt;arutsjak90&lt;/a&gt; -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure you have a calendar table, linked to the "Fixed Date" column in your table, and then try this code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rolling 3 Mo Avg =
VAR __ThisMonth =
    MAX ( COGS[FixedDate] )
VAR __3MoBack =
    EDATE ( __ThisMonth, -3 ) + 1
RETURN
    CALCULATE (
        SUM ( COGS[Total COGS] ),
        ALLEXCEPT ( COGS, COGS[Plant] ),
        DATESBETWEEN ( DateTab[Date], __3MoBack, __ThisMonth )
    ) / 3
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 14:05:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629193#M32985</guid>
      <dc:creator>dedelman_clng</dc:creator>
      <dc:date>2021-01-28T14:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629339#M32991</link>
      <description>&lt;P&gt;Thank you for your time, but it is not working..&amp;nbsp;&lt;BR /&gt;after entering this code, I get the sum of the whole Total COGS column divided by 3, not splited into plants and not rolling, very strange&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 14:49:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629339#M32991</guid>
      <dc:creator>arutsjak90</dc:creator>
      <dc:date>2021-01-28T14:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629340#M32992</link>
      <description>&lt;P&gt;You need to create it as a measure, not as a column.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 14:51:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629340#M32992</guid>
      <dc:creator>dedelman_clng</dc:creator>
      <dc:date>2021-01-28T14:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629397#M32994</link>
      <description>&lt;P&gt;Thanks, but still the same result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 15:09:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629397#M32994</guid>
      <dc:creator>arutsjak90</dc:creator>
      <dc:date>2021-01-28T15:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629406#M32995</link>
      <description>&lt;P&gt;Please share a copy of your pbix with sensitive data removed. Dropbox, Google Drive, OneDrive, GitHub, etc.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 15:12:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629406#M32995</guid>
      <dc:creator>dedelman_clng</dc:creator>
      <dc:date>2021-01-28T15:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629506#M32998</link>
      <description>&lt;P&gt;I have sent it via private message&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 15:48:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629506#M32998</guid>
      <dc:creator>arutsjak90</dc:creator>
      <dc:date>2021-01-28T15:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629520#M33000</link>
      <description>&lt;P&gt;Please post the link in the thread, not PM, in case others want to look at it or help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That being said, you did not create the proper relationships in your model, as instructed. This will cause the measure code to not work correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Link "COSG[Fixed Date]" to DateTab[Date].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 15:52:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629520#M33000</guid>
      <dc:creator>dedelman_clng</dc:creator>
      <dc:date>2021-01-28T15:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629587#M33001</link>
      <description>&lt;P&gt;&lt;A href="https://drive.google.com/drive/folders/16GoTloQOeYLuvgu6eMl6M0LSgKA4iJzj?usp=sharing" target="_blank"&gt;https://drive.google.com/drive/folders/16GoTloQOeYLuvgu6eMl6M0LSgKA4iJzj?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to create calculated column instead of measure?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 16:11:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629587#M33001</guid>
      <dc:creator>arutsjak90</dc:creator>
      <dc:date>2021-01-28T16:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling average with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629748#M33012</link>
      <description>&lt;P&gt;I would not recommend creating it as a calcaulted column. Measures can be used in mostly the same way as columns and are more dynamic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run into an issue using the measure in further calculations, please start a new thread instead of continuing this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 17:02:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-average-with-filter/m-p/1629748#M33012</guid>
      <dc:creator>dedelman_clng</dc:creator>
      <dc:date>2021-01-28T17:02:31Z</dc:date>
    </item>
  </channel>
</rss>

