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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
jostnachs
Helper IV
Helper IV

Setting the default date slicer to current year

Hi all,

I have a requirement where i have a date slicer as below . These are the min and max values in the dataset. Now my requirement is, when i open the report, the report has to show current year (i.e. 01/01/2024  to 31/01/2024) instead of the below values. How can I do that? when I change the relative dates in filter, the user is not allowed to select other years except 2024 . i want user to select other years as well. So can someone suggest how I can do that?

jostnachs_0-1719281416820.png

 

4 REPLIES 4
v-yajiewan-msft
Community Support
Community Support

Hi @jostnachs ,hello  @lbendlin  
Thank you for your prompt reply!

According to your description, you want to “set the default date slicer to current year” and can also filter against all other dates.

 

Per my test, currently the default slicer cannot do this.

 

Therefore, we suggest you use the Preselected Slicer from app source as a workaround.

 

Here are steps you can refer to:

  1. We get the three point in the "Visualizations", and we click the "Get more visual":vyajiewanmsft_2-1719392696992.png
  2. Then we search the "Preselected Slicer" and add the visual to our Power Bi Desktop.vyajiewanmsft_1-1719391961276.png
  3. Then, we create a table with one column , and the value is True and False, like this:vyajiewanmsft_2-1719391961277.png
  4. Later, we can create a measure to define which the date we need to default preselected. If we need to default preselect then we return True else return False.
  5. Flag = var currentYear=YEAR(TODAY())
    VAR _maxcurrentYear=CALCULATE(MAX('Table'[Date]),FILTER('Table',YEAR('Table'[Date])=currentYear))
    var _mincurrentYear=CALCULATE(MIN('Table'[Date]),FILTER('Table',YEAR('Table'[Date])=currentYear))
    var _date = SELECTEDVALUE('Table'[Date])
    return
    IF( _date<= _maxcurrentYear&&_date>=_mincurrentYear,TRUE(),FALSE())
  6. Lastly, we drag the slicer fields, default selected measure and status column as shown below:vyajiewanmsft_0-1719392626621.png

  7. Note: its necessary to click the red reset button in the upper right corner to recover the default selections.vyajiewanmsft_1-1719392646363.png

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

 

Best regards,

 

Joyce

 

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

Thank you so much for the idea.... But using this particular additional visual is hindering the performance of the report. I tried it. The visual takes a lot of time to load and also its not possible to show it as in between slicer which is what the customer requested for......

Hi @jostnachs

Thank you for your feedback, we recommend send your feature request by submitting your ideas in the following link:

https://ideas.fabric.microsoft.com/ 

Best regards,

Joyce

lbendlin
Super User
Super User

Here is the general approach for that pattern:

 

 

- create a string representation of your date column, replace the latest date with a string "Latest"
- sort that new column by the original date column
- add a slicer or visual/page/report level filter
- set the filter to "Latest"
- publish the pbix to the workspace/app

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors