Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
k-m-l
New Member

Rolling Average extended past end of data

I have used the quick measure to calculate a 12 month rolling average for my data. This all works fine. However, PowerBI appears to have forecast the rolling average past my last data point. So the last data point I have in the time series is February 2019, but the rolling average has been calculated until December 2019.

 

Can anyone tell me how PowerBI is calculating these extra values? and why it is calculating them? and how to stop it?

 

I've tried working it out from the DAX and got nowhere!

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @k-m-l 

Create measures as below

7.png

total = SUM(Sheet5[value])

calendar date = MAX('calendar'[Date])

true/flase =
VAR lastpoint =
    CALCULATE ( MAX ( Sheet5[date] ), ALL ( Sheet5 ) )
RETURN
    YEAR ( [calendar date] )
    < YEAR ( lastpoint )
    || (
        YEAR ( [calendar date] ) = YEAR ( lastpoint )
            && MONTH ( [calendar date] ) <= MONTH ( lastpoint )
    )

rolling sum 12 = IF([true/flase]=TRUE(),
	VAR __LAST_DATE = ENDOFMONTH('calendar'[Date].[Date])
	VAR __DATE_PERIOD =
		DATESBETWEEN(
			'calendar'[Date].[Date],
			STARTOFMONTH(DATEADD(__LAST_DATE, -11, MONTH)),
			ENDOFMONTH(DATEADD(__LAST_DATE, 0, MONTH))
		)
	RETURN
		SUMX(
			CALCULATETABLE(
				SUMMARIZE(
					VALUES('calendar'),
					'calendar'[Date].[Year],
					'calendar'[Date].[QuarterNo],
					'calendar'[Date].[Quarter],
					'calendar'[Date].[MonthNo],
					'calendar'[Date].[Month]
				),
				__DATE_PERIOD
			),
			CALCULATE([total], ALL('calendar'[Date].[Day]))
		))

rolling average 12 = [rolling sum 12]/12

6.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @k-m-l 

Is this problem sloved? 

If it is sloved, could you kindly accept it as a solution to close this case?

If not, please let me know.

 

Best Regards

Maggie

v-juanli-msft
Community Support
Community Support

Hi @k-m-l 

Create measures as below

7.png

total = SUM(Sheet5[value])

calendar date = MAX('calendar'[Date])

true/flase =
VAR lastpoint =
    CALCULATE ( MAX ( Sheet5[date] ), ALL ( Sheet5 ) )
RETURN
    YEAR ( [calendar date] )
    < YEAR ( lastpoint )
    || (
        YEAR ( [calendar date] ) = YEAR ( lastpoint )
            && MONTH ( [calendar date] ) <= MONTH ( lastpoint )
    )

rolling sum 12 = IF([true/flase]=TRUE(),
	VAR __LAST_DATE = ENDOFMONTH('calendar'[Date].[Date])
	VAR __DATE_PERIOD =
		DATESBETWEEN(
			'calendar'[Date].[Date],
			STARTOFMONTH(DATEADD(__LAST_DATE, -11, MONTH)),
			ENDOFMONTH(DATEADD(__LAST_DATE, 0, MONTH))
		)
	RETURN
		SUMX(
			CALCULATETABLE(
				SUMMARIZE(
					VALUES('calendar'),
					'calendar'[Date].[Year],
					'calendar'[Date].[QuarterNo],
					'calendar'[Date].[Quarter],
					'calendar'[Date].[MonthNo],
					'calendar'[Date].[Month]
				),
				__DATE_PERIOD
			),
			CALCULATE([total], ALL('calendar'[Date].[Day]))
		))

rolling average 12 = [rolling sum 12]/12

6.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Tried this and this didn't seem to work for me. 

AnthonyTilley
Solution Sage
Solution Sage

can you post the dax formula





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




It's just the DAX that is generated using the quick measure. I haven't changed it at all.

 

ALL _Total rolling average =

IF( ISFILTERED('Date'[Cal_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'[Cal_Date].[Date])

VAR __DATE_PERIOD = DATESBETWEEN( 'Date'[Cal_Date].[Date], STARTOFMONTH(DATEADD(__LAST_DATE, -11, MONTH)), __LAST_DATE )

RETURN AVERAGEX(

CALCULATETABLE(

SUMMARIZE(

VALUES('Date'), 'Date'[Cal_Date].[Year], 'Date'[Cal_Date].[QuarterNo], 'Date'[Cal_Date].[Quarter], 'Date'[Cal_Date].[MonthNo], 'Date'[Cal_Date].[Month] ), __DATE_PERIOD ),

CALCULATE([ALL _Total], ALL('Date'[Cal_Date].[Day])) ) )

I have the same exact issue. I am using the quick measures but for some reason, it shows data 12 months past the current month.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.