<?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: End Of Quarter Moving Average of five previous n quarters at the closing in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2253196#M54339</link>
    <description>&lt;P&gt;Thank you but it isn´t working. The formula, I think, should use closingbalancequarter for using the last value of the quarter, I think I can use the moving average pattern to go back but I don´t know how to tell closingbalance quarter to only carry the closing balance I.e If it is October the last month take the previous 5 Quarterts and do the average...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your help... I have deadlines and I am a little bit...&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Dec 2021 07:30:35 GMT</pubDate>
    <dc:creator>pablofernandez</dc:creator>
    <dc:date>2021-12-23T07:30:35Z</dc:date>
    <item>
      <title>End Of Quarter Moving Average of five previous n quarters at the closing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2251491#M54216</link>
      <description>&lt;P&gt;Hello Guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a big issue trying to get an average of the last endofquarter of the past n quarters ( I want past 5 quarters but It could change)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need that if the quarter doesn´t end the value should take the value only for quarters ended. I.e: If I am in November, the values should be the ones from September, June, March, December (Previous Year), September (Previous Year).&lt;BR /&gt;&lt;BR /&gt;I´ve went with the pattern of moving average, mixing with the endofquarter function. But it is not working properly. Any advice on how I could workorund this issue? Or where my asumption is not right.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;NumOfQuarters&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;= 5&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;LastCurrentDate&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;'Dates'[Dates]&lt;/SPAN&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Period&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;DATESINPERIOD&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;'Dates'[Dates]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;LastCurrentDate&lt;/SPAN&gt;&lt;SPAN&gt;, - &lt;/SPAN&gt;&lt;SPAN&gt;NumOfQuarters&lt;/SPAN&gt;&lt;SPAN&gt;, QUARTER&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;Result&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;D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PAN&gt;FinalData[Date]&lt;/SPAN&gt;&lt;SPAN&gt; )&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;IF&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;FirstDateInPeriod&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;LastDateWithSales&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;Result&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Dec 2021 08:22:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2251491#M54216</guid>
      <dc:creator>pablofernandez</dc:creator>
      <dc:date>2021-12-22T08:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: End Of Quarter Moving Average of five previous n quarters at the closing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2251604#M54223</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="347415" data-lia-user-login="pablofernandez" class="lia-mention lia-mention-user"&gt;pablofernandez&lt;/a&gt; , Try a meausre like &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 5 = CALCULATE(AverageX(values(Date[Quarter Year]), calculate(lastnonblankvalue('Date'[Date]), Sum(Table[Value]))),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-5,Quarter))&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 09:09:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2251604#M54223</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-12-22T09:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: End Of Quarter Moving Average of five previous n quarters at the closing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2253196#M54339</link>
      <description>&lt;P&gt;Thank you but it isn´t working. The formula, I think, should use closingbalancequarter for using the last value of the quarter, I think I can use the moving average pattern to go back but I don´t know how to tell closingbalance quarter to only carry the closing balance I.e If it is October the last month take the previous 5 Quarterts and do the average...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your help... I have deadlines and I am a little bit...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 07:30:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2253196#M54339</guid>
      <dc:creator>pablofernandez</dc:creator>
      <dc:date>2021-12-23T07:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: End Of Quarter Moving Average of five previous n quarters at the closing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2256367#M54463</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="347415" data-lia-user-login="pablofernandez" class="lia-mention lia-mention-user"&gt;pablofernandez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this,&lt;/P&gt;
&lt;P&gt;Dax code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = //get total of the last endofquarter of the past 5 quarters
    var _NumOfQuarters = -5
    var _CurrentDate=DATE(2021,11,2)//TODAY()//If I am in 2021-11-2. you can change it later according to your needs.
    var _Start= STARTOFQUARTER(DATESINPERIOD('calendar'[Date],_CurrentDate,_NumOfQuarters,QUARTER))
    var _End= STARTOFQUARTER(DATESINPERIOD('calendar'[Date],_CurrentDate,1,QUARTER))
return CALCULATE(SUM(Data[Value]),FILTER(ALL(Data),Data[Date]&amp;gt;=_Start &amp;amp;&amp;amp; Data[Date]&amp;lt;_End &amp;amp;&amp;amp; MONTH(Data[Date]) in {3,6,9,12}))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average = 
    var _NumOfQuarters = -5
    var _CurrentDate=DATE(2021,11,2)//TODAY()//
    var _Start= STARTOFQUARTER(DATESINPERIOD('calendar'[Date],_CurrentDate,_NumOfQuarters,QUARTER))
    var _End= STARTOFQUARTER(DATESINPERIOD('calendar'[Date],_CurrentDate,1,QUARTER))
return Divide(CALCULATE(SUM(Data[Value]),FILTER(ALL(Data),Data[Date]&amp;gt;=_Start &amp;amp;&amp;amp; Data[Date]&amp;lt;_End &amp;amp;&amp;amp; MONTH(Data[Date]) in {3,6,9,12})),ABS(_NumOfQuarters))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Tang&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Dec 2021 06:10:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/End-Of-Quarter-Moving-Average-of-five-previous-n-quarters-at-the/m-p/2256367#M54463</guid>
      <dc:creator>v-xiaotang</dc:creator>
      <dc:date>2021-12-27T06:10:07Z</dc:date>
    </item>
  </channel>
</rss>

