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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Alpj
Regular Visitor

Rolling 12 restrict date to less than today, end of the input was reached Issue

Hi All

 

I am new to PowerBI and delved around to try and find a solution to prevent rolling 12 charts extending on beyond todays date and pulled together the following, but i am getting an error end of input reached. I have tried changing the parent thesis but for life of me i cannot figure out what i have done wrong. Any help appreciated 

 

Here is what i have

 

rolling average =
IF(
    ISFILTERED(DatePast[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(DatePast[Date].[Date])
    VAR __DATE_PERIOD =
        DATESBETWEEN(
            DatePast[Date].[Date],
            STARTOFMONTH(DATEADD(__LAST_DATE, -11 , MONTH)),
            __LAST_DATE
        )
    RETURN
        IF (
    YEAR ( __LAST_DATE ) IN ALLSELECTED ( 'Calendar'[Year] ),
            AVERAGEX(
                CALCULATETABLE(
                    SUMMARIZE(
                        VALUES(DatePast),
                        DatePast[Date].[Year],
                        DatePast[Date].[QuarterNo],
                        DatePast[Date].[Quarter],
                        DatePast[Date].[MonthNo],
                        DatePast[Date].[Month]
                ),
                __DATE_PERIOD
            ),
            CALCULATE(SUM(opportunity[totalamount_base]), ALL(DatePast[Date].[Day]]))
        )
))))))))))
1 ACCEPTED SOLUTION

@Alpj , Sorry there was a mistake

use allselected

 

I trying to get max selected date or max available date in selection from fact- Sales in my case

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Alpj ,  Try a measure like

 

Rolling 12 Sales =
var _max = maxx(allselcted(date),date[date]) // or today()

var _max2 = maxx(allselcted(Sales),Sales[date]) //
var _min = date(year(_max), month(_max)-12,1)
return
CALCULATE(SUM(Sales[Sales Amount]),filter(date, date[date] <=_max && date[date] >=_min && date[date]<=_max2 ))

 

 

or

Rolling 12 =

var _max2 = maxx(allselcted(Sales),Sales[date]) //

return

CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH), 'Date'[Date] <= _max2)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you so much for responding, apologies could you explain this a little,

what is the "allselcted(date)" and "allselcted(Sales)" elements?

am i replacing date[date] with my date range table?

what is the "Sales[date]"?

 

Fairly new to all this, so would appreciate if you could give a little explanation 

 

Thank you

 

Ali

@Alpj , Sorry there was a mistake

use allselected

 

I trying to get max selected date or max available date in selection from fact- Sales in my case

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors