cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Monterrach Visitor
Visitor

Monterrach

Inner filter (a copy of) your big enought calendar table with your data table. Add a column like YEAR*10000+MONTH*100+DAY and erase all rows but the last one and you will get a ONE ROW TABLE.

 

Make a DAX expresion like if(isfiltered(A),(if(hasonevalue(A), selectedvalue(A), ¿? ), <one reference here to the one row table that you want to make default>)       

 

A, for example can be the real calendar, or the country list, or the state list or whatever you want to make default behaviour.

 

When you refresh your data, your ONE ROWS TABLES will change, so your defaults also will change. 

 

 

xonde Frequent Visitor
Frequent Visitor

Re: Setting the Default Value of a Slicer

GOOD NEWS!! The Power BI March 2019 Update just released a custom visual called the "Power Slicer" you can import this visual from the marketplace. This visual has a million more options than the normal slicer and more importantly allows you to set a default value. This can be done by going into the format tab under the "selection" options and setting the default value to a literal in your list.

For example if you had a power slicer with a bunch of years in it:
.2015
.2016
.2017
.2018
.2019

 

You can set "Default Selection" to be "2019"(minus the quotes). But if you want it to be dynamic and always show the current year, then even more good news, this options accepts javascript, so you can set the "Default Selection" to "(new Date()).getFullYear"(minus the quotes)  and the Default will always be the current year. If you have a more specific need you can always google it for some javascript help, and someone on StackOverflow will probably have your answer.

Hope this helps,

Xonde.

xonde Frequent Visitor
Frequent Visitor

Re: Setting the Default Value of a Slicer

GOOD NEWS!! The Power BI March 2019 Update just released a custom visual called the "Power Slicer" you can import this visual from the marketplace. This visual has a million more options than the normal slicer and more importantly allows you to set a default value. This can be done by going into the format tab under the "selection" options and setting the default value to a literal in your list.

For example if you had a power slicer with a bunch of years in it:
.2015
.2016
.2017
.2018
.2019

 

You can set "Default Selection" to be "2019"(minus the quotes). But if you want it to be dynamic and always show the current year, then even more good news, this options accepts javascript, so you can set the "Default Selection" to "(new Date()).getFullYear"(minus the quotes)  and the Default will always be the current year. If you have a more specific need you can always google it for some javascript help, and someone on StackOverflow will probably have your answer.

 

Heres a link to the video (Skip to 14:43): https://www.youtube.com/watch?v=rBPGH6eYlT0&feature=youtu.be&t=10

Hope this helps,

Xonde.

Mukovnin Visitor
Visitor

Re: Setting the Default Value of a Slicer

Hi all!

What if I want to month with data will be checked by default after PQuery update. And a month without data just will be shown in the filter? Is it possible?

Untitled.png

Super User
Super User

Re: Setting the Default Value of a Slicer

HI there

Currently that is not possible because when you select something it will keep that month selected.

What would work better is to rather use a value that does not change each month such as "Current Month"

Did I answer your question? Mark my post as a solution!
"Proud to be a Datanaut!"
Power BI Blog
Highlighted
harib Member
Member

Re: Setting the Default Value of a Slicer

@greggyb 

 

Can u please provide the sample file. The one which u have provided the link is not working.

 

Many Thanks 

 

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 311 members 3,200 guests
Please welcome our newest community members: