Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Would it be possible to have a filter on a visualization which allows you to select a year and includes data for the last 4 years? Like for example, if I select 2016, the visualization will include data for 2016, 2015, 2014 and 2013.
@Anonymous
Not sure what does the final visual chart like. But you can try with following steps to see if it is you expected.
YearMonth = YEAR ( 'Calendar'[Date] ) * 100 + MONTH ( 'Calendar'[Date] )
Year = YEAR ( 'Calendar'[Date] )
Year = VALUES ( 'Calendar'[Year] )
Year = YEAR ( Table1[Date] )
TotalSales =
VAR LastDay =
DATE ( MAX ( 'Year'[Year] ), 12, 31 )
VAR FirstDay =
EDATE ( LastDay, -48 )
VAR TotalSales =
SUM ( Table1[Sales] )
RETURN
IF (
MIN ( 'Calendar'[Date] ) < FirstDay,
BLANK (),
IF ( MIN ( 'Calendar'[Date] ) > LastDay, BLANK (), TotalSales )
)Best Regards,
Herbert
This is possible. For example, if I have sales data and I want to choose a year and see the last four years, my calculation might be. You just have to make use of CALCULATE and possibley FILTER. This also depends on whether you want just whole years or if you mean rolling 12 month periods. If you mean rolling periods, you would have to alter your formula and you could probably use DATESBETWEEN instead of the FILTER function in the calculation below.
Last 4 years = CALCULATE(Sum('FactInternetSales'[SalesAmount]), Filter(All('DimDate'),'DimDate'[CalendarYear] <= Max('DimDate'[CalendarYear]) && 'DimDate'[CalendarYear] > MAX('DimDate'[CalendarYear]) - 4))
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!