Forum Discussion
Hide future year(s) from slicer visual
- 3 years ago
The funny thing is that for me the filter pane does not provide a "Relative date" option probably because Power BI reads my "Year" (dData[Ano]) column as integers values, not as actual dates.
But the good news is that I reached a solution by creating the calculated table below with GENERATESERIES.
I then connected the above 'Ano Slicer' table to the date table through dData[Ano] via a one-to-many relationship and when I placed it on the slicer's field pane, voilá, I now have my slice with only the years I want!
My mistake before was that I was replicating this code as a measure, but the slicer's field pane apparently only accepts table columns as data arguments.
Hi leolapa_br
This can be done through adding date field in the filters pane and then setting the filters like below:
It appears that your "Year" field is in text format rather than numerial format. Is this correct? Alternatively, you can also untick "2024" in the "Year" field through filters pane.
I attach an example pbix file.
https://1drv.ms/u/s!AlqFfzVTqicpnXnwYGpHFHW9hZaK?e=J0B7Fk
Hi DataNinja777 and thanks for the reply.
When I was playing with the filters pane I noticed I could manually set limits so the slicer can only show the years up to the current year (2023 as of now), just as you're suggesting.
However, and that's why I highlighted "manually" above, this would only solve the issue at the present moment. Once we get to a new year I would always need to make sure the filter pane is reset to this new upcoming year, and so on, and that unfortunately doesn't work for me.
What I need is a solution that dynamically sets the threshold and therefore needs no manual intervention in the future.
And to answer your question, my "Year" field is in numerical format. Only years are shown on the slicer because I have a column 'dDatas[Ano]' on my dates table that only displays the years.
- DataNinja7773 years ago
Super User
Hi leolapa_br
Certainly. It is better to do it dynamically as you said for easier maintenance. What about setting the filter type as "Relative date" as shown below?
- leolapa_br3 years ago
Resolver II
The funny thing is that for me the filter pane does not provide a "Relative date" option probably because Power BI reads my "Year" (dData[Ano]) column as integers values, not as actual dates.
But the good news is that I reached a solution by creating the calculated table below with GENERATESERIES.
I then connected the above 'Ano Slicer' table to the date table through dData[Ano] via a one-to-many relationship and when I placed it on the slicer's field pane, voilá, I now have my slice with only the years I want!
My mistake before was that I was replicating this code as a measure, but the slicer's field pane apparently only accepts table columns as data arguments.