<?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: 12-month rolling average without dividing the values that are blank. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-month-rolling-average-without-dividing-the-values-that-are/m-p/2127678#M48822</link>
    <description>&lt;P&gt;It totally worked! Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 11 Oct 2021 16:12:59 GMT</pubDate>
    <dc:creator>GA1993</dc:creator>
    <dc:date>2021-10-11T16:12:59Z</dc:date>
    <item>
      <title>12-month rolling average without dividing the values that are blank.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-month-rolling-average-without-dividing-the-values-that-are/m-p/2123808#M48700</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is particularly with the 12-month rolling average. What I did was I utilized the 'Quick Measure' feature of PowerBI and selected the corresponding fields to be calculated for the 12-months. Below was the automatic formula created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RAve_Time to Hire = 
IF(
	ISFILTERED('Date'[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('Date'[Date].[Date])
	VAR __DATE_PERIOD =
		DATESBETWEEN(
			'Date'[Date].[Date],
			STARTOFMONTH(DATEADD(__LAST_DATE, -12, MONTH)),
			__LAST_DATE
		)
	RETURN
		AVERAGEX(
			CALCULATETABLE(
				SUMMARIZE(
					VALUES('Date'),
					'Date'[Date].[Year],
					'Date'[Date].[QuarterNo],
					'Date'[Date].[Quarter],
					'Date'[Date].[MonthNo],
					'Date'[Date].[Month]
				),
				__DATE_PERIOD
			),
			CALCULATE(SUM('MP - Engine'[Time to Hire]), ALL('Date'[Date].[Day]))
		)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This totally worked for those that have values per month. However, the problem takes place when the months are blank or have no values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, the rolling average below should be 100%, but since it was counting those months that had no values/blank, it is getting different rolling average totals.&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;How do I solve this? I am thinking of filtering or placing an IF statement where only those months that have values will be calculated as opposed to dividing it to 12. However, I am not sure how to add this to the code above.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 10:00:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-month-rolling-average-without-dividing-the-values-that-are/m-p/2123808#M48700</guid>
      <dc:creator>GA1993</dc:creator>
      <dc:date>2021-10-08T10:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: 12-month rolling average without dividing the values that are blank.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-month-rolling-average-without-dividing-the-values-that-are/m-p/2124154#M48712</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a sample power bi for you, which contains my solution. If you did not update PBI, you will not be able to open it.&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1cU2fCXboj5cfFwcZNeTkpSwTKuB3PJ-K/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1cU2fCXboj5cfFwcZNeTkpSwTKuB3PJ-K/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To give some context, I tried to break your calculations into multiple steps:&lt;/P&gt;&lt;P&gt;1. You need the Total Hire Time for the last 12 Months&lt;/P&gt;&lt;P&gt;2. This sum must be divided to 12 - N (where N = the blanks) - I assumed you wanted to divide the R12M Time to Hire to the number of months which are not blank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Solution:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;3. Final Measure =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR R12MTotalTimetoHire =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUM ( &lt;STRONG&gt;Table1[Time to Hire]&lt;/STRONG&gt; ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATESINPERIOD ( &lt;STRONG&gt;Table1[Date]&lt;/STRONG&gt;, MAX ( &lt;STRONG&gt;Table1[Date] )&lt;/STRONG&gt;, -12, MONTH )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR BlankMonths =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DISTINCTCOUNT ( &lt;STRONG&gt;Table1[Date] )&lt;/STRONG&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;Table1[Time to Hire]&lt;/STRONG&gt; = 0&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; &lt;STRONG&gt;Table1[Time to Hire]&lt;/STRONG&gt; = BLANK (),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATESINPERIOD ( &lt;STRONG&gt;Table1[Date]&lt;/STRONG&gt;, MAX ( &lt;STRONG&gt;Table1[Date] )&lt;/STRONG&gt;, -12, MONTH )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&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;R12MTotalTimetoHire / ( 12 - BlankMonths )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Look at 12/1/2021 from the below screenshot. The R12M time to hire is 41 (0+5+9+...+10). Then, 41 is divided to 12-5, where 5 represents the number of BLANK months within this time period (1/1/2021 - 12/1/2021). The average is going to be 41/7 = 5.85.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;If this is not the outcome you were hoping for, please share the raw data and some expected results in order to better help you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 12:51:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-month-rolling-average-without-dividing-the-values-that-are/m-p/2124154#M48712</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-08T12:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: 12-month rolling average without dividing the values that are blank.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-month-rolling-average-without-dividing-the-values-that-are/m-p/2127678#M48822</link>
      <description>&lt;P&gt;It totally worked! Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 16:12:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/12-month-rolling-average-without-dividing-the-values-that-are/m-p/2127678#M48822</guid>
      <dc:creator>GA1993</dc:creator>
      <dc:date>2021-10-11T16:12:59Z</dc:date>
    </item>
  </channel>
</rss>

