cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
k-m-l Frequent Visitor
Frequent Visitor

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

Accepted Solutions
Community Support Team
Community Support Team

Re: Rolling Average extended past end of data

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.

4 REPLIES 4
AnthonyTilley Established Member
Established Member

Re: Rolling Average extended past end of data

can you post the dax formula

k-m-l Frequent Visitor
Frequent Visitor

Re: Rolling Average extended past end of data

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])) ) )

Community Support Team
Community Support Team

Re: Rolling Average extended past end of data

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.

Community Support Team
Community Support Team

Re: Rolling Average extended past end of data

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

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 131 members 1,738 guests
Please welcome our newest community members: