<?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: Comparing with a rolling average. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028259#M159158</link>
    <description>&lt;P&gt;HI,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm not sure, why this is not working. The DAX validator is throwing an error.&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;I tried the flag expression, But I can't use it as a filter. Only in the Values area.&lt;/P&gt;</description>
    <pubDate>Sat, 06 Jul 2024 18:09:41 GMT</pubDate>
    <dc:creator>ChiragPatnaik</dc:creator>
    <dc:date>2024-07-06T18:09:41Z</dc:date>
    <item>
      <title>Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028080#M159154</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am looking to create a rolling average of volume for each symbol. and then set a flag if today's/(the day's) volume for the symbol is higher than this average.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is what I have right now.&lt;/SPAN&gt;&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;=CALCULATE(
    AVERAGE(Delivery[TTL_TRD_QNTY]),GROUPBY(Delivery,Delivery[SYMBOL]),
       FILTER(
        ALL(Delivery),
        Delivery[DATE1]&amp;lt;=MAX(Delivery[DATE1]) &amp;amp;&amp;amp; Delivery[DATE1] &amp;gt;= MAX(Delivery[DATE1])-35
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Once I get this in the calculated filed, then it should be a trivial matter to add another field with the flag with a if statement.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I seem to have got the first part right by using GroupBy as you can see in this.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;But when I try to compare that in a new column to set a flag, I get an error.&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;=IF(Delivery[TTL_TRD_QNTY]&amp;gt;Delivery[SMV],"Up","Down")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&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;&lt;P&gt;Is there any way to overcome this? Or a different method perhaps?&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 14:53:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028080#M159154</guid>
      <dc:creator>ChiragPatnaik</dc:creator>
      <dc:date>2024-07-06T14:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028095#M159229</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="771406" data-lia-user-login="ChiragPatnaik" class="lia-mention lia-mention-user"&gt;ChiragPatnaik&lt;/a&gt;&amp;nbsp;- Create two measures one for rolling average and then use another measure for the flag.&lt;/P&gt;&lt;P&gt;RollingAvgVolume =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;AVERAGE(Delivery[TTL_TRD_QNTY]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL(Delivery),&lt;BR /&gt;Delivery[SYMBOL] = MAX(Delivery[SYMBOL]) &amp;amp;&amp;amp;&lt;BR /&gt;Delivery[DATE1] &amp;lt;= MAX(Delivery[DATE1]) &amp;amp;&amp;amp;&lt;BR /&gt;Delivery[DATE1] &amp;gt; MAX(Delivery[DATE1]) - 35&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;another measure for flag:&lt;/P&gt;&lt;P&gt;VolumeFlag =&lt;BR /&gt;IF(&lt;BR /&gt;MAX(Delivery[TTL_TRD_QNTY]) &amp;gt; [RollingAvgVolume],&lt;BR /&gt;"Up",&lt;BR /&gt;"Down"&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution! This will help others on the forum!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 15:02:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028095#M159229</guid>
      <dc:creator>rajendraongole1</dc:creator>
      <dc:date>2024-07-06T15:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028103#M159155</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="771406" data-lia-user-login="ChiragPatnaik" class="lia-mention lia-mention-user"&gt;ChiragPatnaik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are almost always better off doing a measure rather than a calculated&amp;nbsp;column because the column only recalculates when the model is refreshed.&amp;nbsp; Does this measure give you to rolling average you are expecting?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rolling Average =
VAR _MaxDate = CALCULATE ( MAX ( Delivery[DATE1] ), ALL ( Delivery[DATE1] ) )
VAR _Start = _MaxDate - 35
RETURN
    CALCULATE (
        AVERAGE ( Delivery[TTL_TRD_QNTY] ),
        DATESBETWEEN ( Delivery[DATE1], _Start, _MaxDate )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 15:17:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028103#M159155</guid>
      <dc:creator>jdbuchanan71</dc:creator>
      <dc:date>2024-07-06T15:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028143#M159156</link>
      <description>&lt;P&gt;Unfortunately, this is not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;SMA36 is your formula. SMA362 is the one I posted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The one you posted, is not moving by day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Incidentally, the one I posted is also saved as a measure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 15:57:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028143#M159156</guid>
      <dc:creator>ChiragPatnaik</dc:creator>
      <dc:date>2024-07-06T15:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028151#M159226</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="771406" data-lia-user-login="ChiragPatnaik" class="lia-mention lia-mention-user"&gt;ChiragPatnaik&lt;/a&gt;&amp;nbsp;-can you try below measure for rolling average as a measure and then use another measure for the flag as beloe&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Measure 1:&lt;/P&gt;&lt;P&gt;RollingAvgVolume =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;AVERAGE(Delivery[TTL_TRD_QNTY]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL(Delivery),&lt;BR /&gt;Delivery[SYMBOL] = MAX(Delivery[SYMBOL]) &amp;amp;&amp;amp;&lt;BR /&gt;Delivery[DATE1] &amp;lt;= MAX(Delivery[DATE1]) &amp;amp;&amp;amp;&lt;BR /&gt;Delivery[DATE1] &amp;gt; MAX(Delivery[DATE1]) - 35&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;Measure 2:&lt;/P&gt;&lt;P&gt;another measure for flag&lt;/P&gt;&lt;P&gt;VolumeFlag =&lt;BR /&gt;IF(&lt;BR /&gt;MAX(Delivery[TTL_TRD_QNTY]) &amp;gt; [RollingAvgVolume],&lt;BR /&gt;"Up",&lt;BR /&gt;"Down"&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution! This will help others on the forum!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 16:02:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028151#M159226</guid>
      <dc:creator>rajendraongole1</dc:creator>
      <dc:date>2024-07-06T16:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028169#M159157</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="771406" data-lia-user-login="ChiragPatnaik" class="lia-mention lia-mention-user"&gt;ChiragPatnaik&lt;/a&gt;&amp;nbsp;- Not sure , why my solution is disappeared for this question, again posting on the same thread. please check the below measure for rolling ag. and flag.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RollingAvgVolume =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;AVERAGE(Delivery[TTL_TRD_QNTY]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL(Delivery),&lt;BR /&gt;Delivery[SYMBOL] = MAX(Delivery[SYMBOL]) &amp;amp;&amp;amp;&lt;BR /&gt;Delivery[DATE1] &amp;lt;= MAX(Delivery[DATE1]) &amp;amp;&amp;amp;&lt;BR /&gt;Delivery[DATE1] &amp;gt; MAX(Delivery[DATE1]) - 35&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create a flag measure as below:&lt;/P&gt;&lt;P&gt;VolumeFlag =&lt;BR /&gt;IF(&lt;BR /&gt;MAX(Delivery[TTL_TRD_QNTY]) &amp;gt; [RollingAvgVolume],&lt;BR /&gt;"Up",&lt;BR /&gt;"Down"&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution! This will help others on the forum!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 16:12:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028169#M159157</guid>
      <dc:creator>rajendraongole1</dc:creator>
      <dc:date>2024-07-06T16:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028175#M159230</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="771406" data-lia-user-login="ChiragPatnaik" class="lia-mention lia-mention-user"&gt;ChiragPatnaik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get it to move by day you just need to adjust it a bit.&amp;nbsp; Sorry, I was thinking you wanted the current 35 days always.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rolling Average = 
VAR _MaxDate = MAX ( Delivery[DATE1] )
VAR _Start = _MaxDate - 35
RETURN
    CALCULATE (
        AVERAGE ( Delivery[TTL_TRD_QNTY] ),
        DATESBETWEEN ( Delivery[DATE1], _Start, _MaxDate )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 06 Jul 2024 16:16:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028175#M159230</guid>
      <dc:creator>jdbuchanan71</dc:creator>
      <dc:date>2024-07-06T16:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing with a rolling average.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028259#M159158</link>
      <description>&lt;P&gt;HI,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm not sure, why this is not working. The DAX validator is throwing an error.&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;I tried the flag expression, But I can't use it as a filter. Only in the Values area.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 18:09:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-with-a-rolling-average/m-p/4028259#M159158</guid>
      <dc:creator>ChiragPatnaik</dc:creator>
      <dc:date>2024-07-06T18:09:41Z</dc:date>
    </item>
  </channel>
</rss>

