cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Setting the Default Value of a Slicer

The client has data which is updated monthly and the dashboard contains a chart and a slicer which is set to the current month. They would like the slicer to change the default selection when the data for the new month is loaded.  For example, the current month selected in the slicer is January, and they would like the month selected change to February when that datat is loaded so the corresponding chart will show the data for the latest month.

 

I am drawing a blank as to how you would make this happen. Can someone point me in the right direction?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resident Rockstar
Resident Rockstar

Re: Setting the Default Value of a Slicer

You can't do this directly in the report designer, but you should be able to do some modelling to make it work. See the sample .pbix file here.

 

Basically you make a new field based on the following bit of Power Query M:

if Date.IsInCurrentMonth( [Date] )
then "Current Month"
else [Month]

Then you set the slicer to "Current Month", when the month changes and the dataset is refreshed, the slicer's "Current Month" selection can remain the same. What "Current Month" actually refers to has changed, but not the literal slicer selection.

 

As a bonus, you get a sneak peek at a few snippets from my personal work-in-progress ultimate date table in that .pbix. I'll be publishing the full version once I finalize.

View solution in original post

26 REPLIES 26
Highlighted
Resident Rockstar
Resident Rockstar

Re: Setting the Default Value of a Slicer

You can't do this directly in the report designer, but you should be able to do some modelling to make it work. See the sample .pbix file here.

 

Basically you make a new field based on the following bit of Power Query M:

if Date.IsInCurrentMonth( [Date] )
then "Current Month"
else [Month]

Then you set the slicer to "Current Month", when the month changes and the dataset is refreshed, the slicer's "Current Month" selection can remain the same. What "Current Month" actually refers to has changed, but not the literal slicer selection.

 

As a bonus, you get a sneak peek at a few snippets from my personal work-in-progress ultimate date table in that .pbix. I'll be publishing the full version once I finalize.

View solution in original post

Highlighted
Helper III
Helper III

Re: Setting the Default Value of a Slicer

What a clever idea. Thanks for the tip, I never would have thought of that.  Sending the code was most appreciated too.

Highlighted
Regular Visitor

Re: Setting the Default Value of a Slicer

This also seems like the right solution for me - and thanks for your answer to my other post ....but I can't follow where/how to paste the code and can't access your pbx file. is there an online Power BI tutorial you can point me to where I can see it illustrated? If i paste your formula into the formula bar for a new column it appears to have an issue with the square brackets. thanks again.

Highlighted
Resident Rockstar
Resident Rockstar

Re: Setting the Default Value of a Slicer

@jbowler, the code I shared is from Power Query, which you can access using the Edit Queries ribbon menu item. There's a self-paced edX course designed by Microsoft, with its own forum in this community.

Highlighted
Regular Visitor

Re: Setting the Default Value of a Slicer

If you publish this report to power BI service while the current month in the slicer is selected then open the report form the power BI report which you just published to https://msit.powerbi.com after logging in to it. Then the slicer is not visible .You cannot see any of the data but if you click  on "..." and export to CSV you will see there is data but the slicer with selected value will not visible at all. What is the workaround to fix such kind of issue?

Highlighted
Regular Visitor

Re: Setting the Default Value of a Slicer

Any idea on this is appreciated. Here is the print screen

before.pngAfter.png

 

placeholder.png

 

Highlighted
Regular Visitor

Re: Setting the Default Value of a Slicer

Hi all, 

I am hoping someone is able to help me.  I have a report that contains mutiple slicers to enable the user to select a given year, month and a specific day.  I have used the solution suggested by Greggyb within this thread which has worked brilliantly to give me the 'Current Month'.  However, I now need to do the same thing so that the slicer will default to the current day.  I have tried mutilpe things but am drawing a blank.  I'm just wondering if anyone else has tried to do something similar or if I'm wasting my time and there is another solution I have missed.  I would be grateful for any suggestions and thanks in advance

Highlighted
Advocate I
Advocate I

Re: Setting the Default Value of a Slicer

I have the same problem. I also need to set the default value for Today's Date when opening the Dashboard/Report. 

Highlighted
Resolver I
Resolver I

Re: Setting the Default Value of a Slicer

*Link Added*

Refer to this post for a better solution using DAX Current Month Using DAX.

 

 

Thanks,

Fahd

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors
Users online (786)