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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
bijntjede2e
New Member

Dynamic filtering

Hi,

 

I was wondering if I can apply a dynamic filter in Desktop.

A table (directly to SQL Server OLTP DB) has column [Year] (= transactional year) and I added custom column [CurrYear] to that recordset in the Power BI Query Editor which holds the current year.

Another table in Power BI holds the time "dimension" (from year 1990 until year 2030).

I have a slicer that pulls the years from this dimension, but I would like to filter the years in this slicer to only the years between the current year and the last 3 years. So [Year] between [CurrYear] and [CurrYear] - 3.

As far as I can see I can only enter static values in the filter editor (i.e. [Year] between 2013 and 2016).

Is there a way to use dynamic values?

 

Thanks!

 

regards,

Michiel

2 REPLIES 2
fbrossard
Kudo Commander
Kudo Commander

Hi @bijntjede2e

You could enrich your date table by adding a calculated column for relative year

Relative Year = INT(YEAR([Date]) - YEAR(TODAY()))

and use it as filter onto your report, page or visual.and select the values according to the scope you want to analyze, in your example 0,-1,-2.

 

 

konstantinos
Memorable Member
Memorable Member

The best eway to accomplish that is in query editor since you will end up with a smaller data model.. @greggyb has a great solution in query editor that is exact what you need ( I thing for rlolling months but you can adjust it for years ) but I cannot dig up his post..

 

If he cannot reply I wrote a post how to create dynamic filtering in Query editor but is based on dates in other tables..i.e if you need the date dimention to contain dates that are only is transactional table..

 

https://medium.com/@Konstantinos_Ioannou/powerquery-dynamic-date-dimension-table-filtering-f9201cf87...

Konstantinos Ioannou

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.