title: Power BI Rolling Average
body: <p>I've used the new <strong>Quick Measures</strong> feature of Power BI to build a 3 month rolling average calculation and it's working well. The equation is displayed below. However, when I try to use this metric in a time series visualization, the calculations are displaying three months past the current month, but I'd like for the calculation to stop at the current month. </p>
  
  <p>I've played around with the __DATE_PERIOD variable to no avail. My date filter for the page is set to show all dates in the current months or 12 months prior via a calculated column on the date table. </p>
  
  <p>Is anyone aware of how I can get the visualization to end at the current month?</p>
  
  <pre><code>Average Days to Close Rolling Average = 
  IF(
      ISFILTERED('Date'[Date]),
      ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy."),
      VAR __LAST_DATE =
          ENDOFMONTH('Date'[Date].[Date])
      VAR __DATE_PERIOD =
          DATESBETWEEN(
              'Date'[Date].[Date],
              STARTOFMONTH(DATEADD(__LAST_DATE, -3, 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(
                  'Closed Opportunities'[Average Days to Close],
                  ALL('Date'[Date].[Day])
              )
          )
  )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/dpurp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dpurp.png" alt="enter image description here"></a></p>