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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
LeroyPaul
Helper I
Helper I

Slicer filter on N previous Year

Hello,

I would like to use a slicer on my year field to display the desired year and the 5 previous years.

According to the different solutions that I could find online, I created a 2nd table with years to filter my other table with the following measure (année means year in french) :

 

Mfilter =
VAR minselected =
SELECTEDVALUE('Year Table'[Année])-5
RETURN
VAR maxselected =
SELECTEDVALUE('Year Table'[Année])
RETURN
IF(AND(MAX('5 - Requêtes BO Consolidé'[Année d'octroi (projet)])>=minselected,MAX('5 - Requêtes BO Consolidé'[Année d'octroi (projet)])<=maxselected),1,0)

 

However the measure does not achieve what I want, I get the result below for the year 2021 selected (in Year Table):

 

Année d'octroi (projet)Mfilter
20150
20160
20170
20180
20190
20200
20210

 

Could you help me? (I specify that I am under Power BI 2020)

 

Thanks in advance !

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @LeroyPaul ,

 

Check below measure:

Measure = 
var start_ = SELECTEDVALUE('Year Table'[Année])-5
var end_ = SELECTEDVALUE('Year Table'[Année])
var date1 = SELECTEDVALUE('5 - Requêtes BO Consolidé'[Année d'octroi (projet)])
return
IF(date1>=start_&&date1<=end_,1,0)

Make sure there's no relationship between year table and fact table.

vjaywmsft_0-1666944263179.png

 

Best Regards,

Jay

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @LeroyPaul ,

 

Check below measure:

Measure = 
var start_ = SELECTEDVALUE('Year Table'[Année])-5
var end_ = SELECTEDVALUE('Year Table'[Année])
var date1 = SELECTEDVALUE('5 - Requêtes BO Consolidé'[Année d'octroi (projet)])
return
IF(date1>=start_&&date1<=end_,1,0)

Make sure there's no relationship between year table and fact table.

vjaywmsft_0-1666944263179.png

 

Best Regards,

Jay

Thank you very much, that's exactly it!

PVO3
Impactful Individual
Impactful Individual

This will problably help you.

There must be a more simple solution, I can't adapt the solution of the video to my problem

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.