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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jhaast
Helper II
Helper II

Dynamic year filter

Hi People,

 

Currently, I create visualisations and yearfilters in PBI desktop. 

After uploading those reports to PBI Service I select e.g. the year 2020 and pin a visualisation to an dashboard.

Howerver, when the year changes to e.g. 2021, the visual should be pinned again to the dashboard with the year filter selected on 2021.
Currently I've changed the filter to "Current year", "Prior year", "Two years ago", but  the end-user should every time calculate how many years ago a specific year is.

Does somebody know how I can pin a visual to a dashboard by selecting a year with the normal filter?

 

jhaast_0-1612782601409.png

 

1 ACCEPTED SOLUTION

Hi, @jhaast 

 

Yes, you can. You don't need to use slicer. You can use a measure in the filterpane of the visuals you want to pin to the dashboard, then it will change dynamically.

Like this:

Measure =
VAR a =
    YEAR ( TODAY () )
RETURN
    IF ( VALUES ( 'Table'[Year] ) IN { a, a - 1, a - 2 }, 1, 0 )
//if you use date ,you can try:IF ( Year ( 'Table'[Date] ) IN { a, a - 1, a - 2 }, 1, 0 )

1.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-janeyg-msft
Community Support
Community Support

Hi, @jhaast 

 

The slicer cannot be pinned to the dashboard, so what is the data you put on the dashboard, measure or column? Can you explain it in detail?

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Items which I would pin to the dashboard are:

- A table like this one:

jhaast_0-1613058827477.png

- Or a bar chart like this one:

jhaast_1-1613058904600.png

 

So currently, 2019, 2020 en 2021 are manually select but when the year changes to 2022 I would see 2020, 2021 and 2022 and I need to change the years manually. It would be great if I could select last two years and current year with a relative date filter.

An solution should be the option to select current year in the filter / slicers below: 

jhaast_2-1613059034630.png

jhaast_5-1613059162785.png

 

 

Like the posibility to select "Today" for the filtering in days.

jhaast_3-1613059074884.png

jhaast_4-1613059156636.png

 

Could this be possible?

 

 

 

Hi, @jhaast 

 

Yes, you can. You don't need to use slicer. You can use a measure in the filterpane of the visuals you want to pin to the dashboard, then it will change dynamically.

Like this:

Measure =
VAR a =
    YEAR ( TODAY () )
RETURN
    IF ( VALUES ( 'Table'[Year] ) IN { a, a - 1, a - 2 }, 1, 0 )
//if you use date ,you can try:IF ( Year ( 'Table'[Date] ) IN { a, a - 1, a - 2 }, 1, 0 )

1.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ibarrau
Super User
Super User

Hi. You can try relative date slicer. If that year has a date column somewhere, you can do this. If it doesn't, just create it like YEAR-01-01. The relative will let you pick "This Year" considering TODAY date. You can also use last N months/year if that was the case.

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range#:~:text=With%20th....

Hope that helps


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Hi,

 

That helps, thank you! If I want to select current year and last two years(2019-1-1 -> 2021-02-08) is that also possible with the relative data range slicer? 

Mmm.... I don't think so. If you want something that custom you might need to play with a Calendar Table.

The relative will let you filter by last year (from today's date to 365 days before) or last year (calendar) (e.g. filtering completed years, if you put 1 last calendar year would be filtering by 2020)

Hope that make sense


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.