<?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: Better Rolling Average in Quick Measures Gallery</title>
    <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Better-Rolling-Average/m-p/4373578#M1158</link>
    <description>&lt;P&gt;I have adapted your code to work on days:&lt;BR /&gt;&lt;BR /&gt;```dax&lt;BR /&gt;DAILY_MOVING_AVERAGE =&lt;BR /&gt;// Previous day&lt;BR /&gt;VAR _End = MAX(CALENDAR[DATE]) -1&lt;BR /&gt;// Date for N months ago&lt;BR /&gt;VAR _Start = EDATE(_End, -MONTHLY_MOVING_AVERAGE[MONTHLY_MOVING_AVERAGE Value])&lt;BR /&gt;VAR _OutTable =&lt;BR /&gt;SUMMARIZE(&lt;BR /&gt;// Filter using all of the calendar dimension table&lt;BR /&gt;FILTER(ALL(CALENDAR),CALENDAR[DATE]&amp;gt;=_Start &amp;amp;&amp;amp; CALENDAR[DATE]&amp;lt;=_End),&lt;BR /&gt;CALENDAR[DATE],&lt;BR /&gt;"__Value",[SUM_COUNT]&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;AVERAGEX(_OutTable,[__Value])&lt;BR /&gt;```&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2025 12:00:31 GMT</pubDate>
    <dc:creator>HirotoStarParks</dc:creator>
    <dc:date>2025-01-21T12:00:31Z</dc:date>
    <item>
      <title>Better Rolling Average</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Better-Rolling-Average/m-p/2897874#M911</link>
      <description>&lt;P&gt;Continuing with exploring alternatives to Power BI's default quick measures that don't involve the CALCULATE function, such as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Running-Total/td-p/2755666" target="_self"&gt;Better Running Total&lt;/A&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Average-per-Category/td-p/2758871" target="_self"&gt;Better Average per Category&lt;/A&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Weighted-Average-per-Category/td-p/2805460" target="_self"&gt;Better Weighted Average per Category&lt;/A&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Filtered-Value/td-p/2828654" target="_self"&gt;Better Filtered Value&lt;/A&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Sales-from-New-Customers/td-p/2843073" target="_self"&gt;Better Sales from New Customers&lt;/A&gt;, and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Year-to-Date-Total/td-p/2875532" target="_self"&gt;Year to Date Total&lt;/A&gt;&amp;nbsp;and &lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Year-Over-Year-Change/td-p/2886015" target="_self"&gt;Year Over Year Change&lt;/A&gt;, this one tackles Rolling Average.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI's Rolling Average quick measure returns something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Value rolling average = 
IF(
	ISFILTERED('Dates'[Date]),
	ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
	VAR __LAST_DATE = ENDOFMONTH('Dates'[Date].[Date])
	VAR __DATE_PERIOD =
		DATESBETWEEN(
			'Dates'[Date].[Date],
			STARTOFMONTH(DATEADD(__LAST_DATE, -3, MONTH)),
			__LAST_DATE
		)
	RETURN
		AVERAGEX(
			CALCULATETABLE(
				SUMMARIZE(
					VALUES('Dates'),
					'Dates'[Date].[Year],
					'Dates'[Date].[QuarterNo],
					'Dates'[Date].[Quarter],
					'Dates'[Date].[MonthNo],
					'Dates'[Date].[Month]
				),
				__DATE_PERIOD
			),
			CALCULATE(SUM('Table'[Value]), ALL('Dates'[Date].[Day]))
		)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps a better way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Better Rolling Average = 
    VAR __EndDate = MAX('Table'[Date])
    VAR __3MonthsAgo = EOMONTH(__EndDate, -3)
    VAR __StartDate = DATE(YEAR(__3MonthsAgo), MONTH(__3MonthsAgo), 1)
    VAR __Table = 
        SUMMARIZE(
            FILTER(ALL('Table'),[Date]&amp;gt;=__StartDate &amp;amp;&amp;amp; [Date]&amp;lt;=__EndDate),
            'Table'[Month],
            "__Value",SUM('Table'[Value])
        )
RETURN
    AVERAGEX(__Table,[__Value])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the video:&lt;/P&gt;
&lt;P&gt;&lt;div data-video-id="https://youtu.be/TkrHfRFjpSc" data-video-remote-vid="https://youtu.be/TkrHfRFjpSc" class="lia-video-container lia-media-is-center lia-media-size-medium"&gt;&lt;iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTkrHfRFjpSc%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTkrHfRFjpSc&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTkrHfRFjpSc%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" allowfullscreen="" style="max-width: 100%"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="reportid hidden"&gt;eyJrIjoiZjc5MDlhYjktOWYzZi00YzM3LWFlYWEtYWMyMGQyNzM4NGYwIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 15:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Better-Rolling-Average/m-p/2897874#M911</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-02-04T15:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Better Rolling Average</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Better-Rolling-Average/m-p/4373578#M1158</link>
      <description>&lt;P&gt;I have adapted your code to work on days:&lt;BR /&gt;&lt;BR /&gt;```dax&lt;BR /&gt;DAILY_MOVING_AVERAGE =&lt;BR /&gt;// Previous day&lt;BR /&gt;VAR _End = MAX(CALENDAR[DATE]) -1&lt;BR /&gt;// Date for N months ago&lt;BR /&gt;VAR _Start = EDATE(_End, -MONTHLY_MOVING_AVERAGE[MONTHLY_MOVING_AVERAGE Value])&lt;BR /&gt;VAR _OutTable =&lt;BR /&gt;SUMMARIZE(&lt;BR /&gt;// Filter using all of the calendar dimension table&lt;BR /&gt;FILTER(ALL(CALENDAR),CALENDAR[DATE]&amp;gt;=_Start &amp;amp;&amp;amp; CALENDAR[DATE]&amp;lt;=_End),&lt;BR /&gt;CALENDAR[DATE],&lt;BR /&gt;"__Value",[SUM_COUNT]&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;AVERAGEX(_OutTable,[__Value])&lt;BR /&gt;```&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 12:00:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Better-Rolling-Average/m-p/4373578#M1158</guid>
      <dc:creator>HirotoStarParks</dc:creator>
      <dc:date>2025-01-21T12:00:31Z</dc:date>
    </item>
  </channel>
</rss>

