<?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: Moving average with parameters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-average-with-parameters/m-p/4109928#M163112</link>
    <description>&lt;P&gt;Its due to selection on this slicer&amp;nbsp;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;So its basically plotting averages X months ahead of a given month&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2024 22:47:57 GMT</pubDate>
    <dc:creator>SachinNandanwar</dc:creator>
    <dc:date>2024-08-20T22:47:57Z</dc:date>
    <item>
      <title>Moving average with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-average-with-parameters/m-p/4108954#M163053</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to calculate moving average which time frame will be affected by choosen month. If I choose May, the Montly Sales Chart is showing data up to May. Would like to achieve also with moving average. Can anybody help me how to make it?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Moving Average Quantity (Months Table) = 
VAR ChoosenMonth = Months[Month Value]
Var ChoosenYear = SELECTEDVALUE('Calendar'[Year_ID])
VAR AverageDay = [Selected Moving Average]

VAR LastTransactionDate = MAX('Calendar'[Transaction_Date])
    
VAR PeriodInVisual = 
FILTER(
    ALL('Calendar'[Transaction_Date]),
    'Calendar'[Transaction_Date] &amp;gt; LastTransactionDate - AverageDay &amp;amp;&amp;amp;
    'Calendar'[Transaction_Date] &amp;lt;= LastTransactionDate
    
)

VAR Result = 
CALCULATE(
    [Average Quantity (Months Table)],
    PeriodInVisual
)
RETURN

Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File:&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/19l4_3RTl2TfXW8vNQ_Usq45j912IYNua/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/19l4_3RTl2TfXW8vNQ_Usq45j912IYNua/view?usp=sharing&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 10:08:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-average-with-parameters/m-p/4108954#M163053</guid>
      <dc:creator>gumis_rulez</dc:creator>
      <dc:date>2024-08-20T10:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Moving average with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-average-with-parameters/m-p/4109928#M163112</link>
      <description>&lt;P&gt;Its due to selection on this slicer&amp;nbsp;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;So its basically plotting averages X months ahead of a given month&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 22:47:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-average-with-parameters/m-p/4109928#M163112</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-08-20T22:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Moving average with parameters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-average-with-parameters/m-p/4110832#M163149</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;Firstly&amp;nbsp; SachinNandanwar&amp;nbsp;thank you for your solution!&lt;BR /&gt;And&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="749867" data-lia-user-login="gumis_rulez" class="lia-mention lia-mention-user"&gt;gumis_rulez&lt;/a&gt;&amp;nbsp; to my understanding,you want to align the month in which Moving Average Quantity occurs with the Average Quantity value, your DAX statement is working, the problem is mainly in the field, we can add some filters to our visual object to achieve what you need.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;a = IF(
   [Average Quantity (Months Table)]&amp;lt;&amp;gt;BLANK(),
   1,
   0)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&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;Hope it helps!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Community Support Team_ Tom Shen&lt;/P&gt;
&lt;P&gt;If this post helps then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:15:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Moving-average-with-parameters/m-p/4110832#M163149</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-21T09:15:30Z</dc:date>
    </item>
  </channel>
</rss>

