<?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 6 Month Average for data which has missing dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4003359#M156166</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="687567" data-lia-user-login="afaro" class="lia-mention lia-mention-user"&gt;afaro&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You should ensure your model and relationships are correctly. Could you share your data model and relationships that we can better get and find out your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired out put and pbix file without privacy information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Ada Wang&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jun 2024 05:51:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-21T05:51:23Z</dc:date>
    <item>
      <title>Rolling 6 Month Average for data which has missing dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4002862#M156121</link>
      <description>&lt;P&gt;Before I begin, I want to not use AVERAGEX or DATESINPERIOD in my solution. I would prefer to only use basic functions like CALCULATE, MIN, MAX, FILTER, ALL, etc. I have described my attempt at the end.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have data like this in a table called Sales&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Revenue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 Jan 2021&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12 Jan 2021&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3 Feb 2022&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7 Feb 2022&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9 Mar 2022&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6 April 2022&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20 May 2022&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12 June 2022&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18 June 2022&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12 July 2022&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31 July 2022&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8 August 2022&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Calendar table has daily granularity and I created a bridge Year-Month table to connect my calendar table with the above Sales table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So I have Month-Year from Calendar table as rows and I tried writing this as value for each Month-Year like this:&lt;BR /&gt;Rolling 6 Month Average =&amp;nbsp;&lt;BR /&gt;var maxCurMonthDate = EOMONTH(Calendar[Date],0)&lt;BR /&gt;var prev6Date = EOMONTH(maxCurMonthDate, -6)&amp;nbsp;&lt;BR /&gt;var rollingRevenue = CALCULATE(SUM(Sales[Revenue]), FILTER(ALL(Calendar), Calendar[Date] &amp;lt;= maxCurMonthDate &amp;amp;&amp;amp; Calendar[Date] &amp;gt; prev6Date))&lt;BR /&gt;&lt;BR /&gt;return DIVIDE(rollingRevenue, 6)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This isn't working for some reason and I am looking for insights into why this isn't working.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 22:57:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4002862#M156121</guid>
      <dc:creator>afaro</dc:creator>
      <dc:date>2024-06-20T22:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling 6 Month Average for data which has missing dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4003359#M156166</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="687567" data-lia-user-login="afaro" class="lia-mention lia-mention-user"&gt;afaro&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You should ensure your model and relationships are correctly. Could you share your data model and relationships that we can better get and find out your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired out put and pbix file without privacy information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Ada Wang&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 05:51:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4003359#M156166</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-21T05:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling 6 Month Average for data which has missing dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4003750#M156215</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="687567" data-lia-user-login="afaro" class="lia-mention lia-mention-user"&gt;afaro&lt;/a&gt;&amp;nbsp;- My immediate assumption would be that it's something to do with your relationships or the fields that you have in the chart.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not clear why you have created the Month Year bridge to connect the fact to the calendar when you have dates in both - my first suggestion would be to remove the bridge and join on dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also check that you are using the date from the calendar in your visual - rather than the date from sales.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know you said you don't want to use these, but I have always calculated a moving AVG by using the below - it's very efficient and optimal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR NumOfMonths = 6
VAR LastCurrentDate =
    MAX ( 'Date_Table'[Date] )
VAR Period =
    DATESINPERIOD ( 'Calendar'[Date], LastCurrentDate, - NumOfMonths, MONTH )
VAR Result =
    CALCULATE (
        AVERAGEX ( VALUES ( 'Calendar'[Month Year] ), [Revenue] ),
        Period
    )
VAR FirstDateInPeriod =
    MINX ( Period, 'Calendar'[Date] )
VAR LastDateWithSales =
    MAX ( 'Sales'[Date] )
RETURN
    IF ( FirstDateInPeriod &amp;lt;= LastDateWithSales, Result )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps, if testing this works, please accept it as the solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 09:25:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4003750#M156215</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-06-21T09:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling 6 Month Average for data which has missing dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4004216#M156269</link>
      <description>&lt;P&gt;Because even though my Sales table has dates, it doesn't have every single date. In a given month there are not more than 10 dates for that month. Hence, the last date of that month is usually not there. That is why I created a year-month bridge table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 13:52:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rolling-6-Month-Average-for-data-which-has-missing-dates/m-p/4004216#M156269</guid>
      <dc:creator>afaro</dc:creator>
      <dc:date>2024-06-21T13:52:06Z</dc:date>
    </item>
  </channel>
</rss>

