Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello,
I have a problem with selections in a slicer.
In my slicer I have the column calendar[Year], it contains 2021,2022,2023,2024,2025,2026. I want the current year to be selected, however, all years should be visible in the slicer.
The problem is when I create a calculated column where IsCurrentYear = if(Max(calendar[Year])=Year(Today()),1,0) and I select IsCurrentYear = 1 as a filter in the slicer only the current year appears. I want the current year to be selected but all others should appear.
Thank you for the help
Solved! Go to Solution.
Hi @MSchultz93 ,
You cannot have the selection of the current year based on a filter since it will only return the selected value.
The pre-selected value of a slicer can only be done by selecting the value and when you publish it that will be the default selection, or using a bookmark that will force that specific slicer to select the current year. however in both case if the year changes you need to go back and change it to the new year.
For this default selection of current year I usually create a column with the text Current Year and the rest of the years as numbers then I place the default value for that current year on the slicer so when the year changes the default selectionn get updated.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @MSchultz93 To accomplish this create a year table with all distinct year values in power query. Sort year in ascending order. Create an index column from 0. Create a currentYear custom column using the formula shown in the image below.
Now recalculate Index column using the formula shown in the below:
Now change type of sort index to whole number and CurrentYear to text. Remove Index column. See Image:
Load data to power bi. Create on to many relationship using year column of the above table to calendar table year column.
Now sort the newly created Current Year column by sort index column. See image below:
Go to report page, create slicer and place the newly created current year column in values section. See image below:
Hope this helps!!
If this solved your problem, Please accept it as a solution!!
Best Regards,
Shahariar Hafiz
Create the Measure:
IsCurrentYear = IF(YEAR(TODAY()) = MAX('Calendar'[Year]), 1, 0)
Add the Slicer:
Calendar[Year] column.
Create the Bookmark:
View tab and open the Bookmarks pane.
Add the Button:
Action properties of the button.
Bookmark.
Hi @MSchultz93 ,
You cannot have the selection of the current year based on a filter since it will only return the selected value.
The pre-selected value of a slicer can only be done by selecting the value and when you publish it that will be the default selection, or using a bookmark that will force that specific slicer to select the current year. however in both case if the year changes you need to go back and change it to the new year.
For this default selection of current year I usually create a column with the text Current Year and the rest of the years as numbers then I place the default value for that current year on the slicer so when the year changes the default selectionn get updated.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsMarch 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
82 | |
81 | |
52 | |
39 | |
35 |
User | Count |
---|---|
95 | |
79 | |
52 | |
49 | |
47 |