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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Slicer default option

I have created a slicer to filter the page either based on the Sale or Profit as shown in the picture: 

 

 

Q6.png

 

 

Therefore, we should select either Sale or Profit. but When we select two of them or neither, everything goes blank, as follow:

 

Q7.png

 

How do I solve this? 
how to set or what to set as a default value for slicer?

2 ACCEPTED SOLUTIONS

Hi @Anonymous,

 

Based on your sample, I found that the issue is caused by the measure Final Selection your created. 

 

If you use values function it will return mutiple values which will cause this error.

 

Please modify your measure like below to have a try.

 

Final Selection = SWITCH(TRUE(), 
    SELECTEDVALUE(Selection[Option])= "Sales", [Total Internet Sale],
    SELECTEDVALUE(Selection[Option])= "Profits", [Total Internet Profit], 0)

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

xonde
Frequent Visitor

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.

View solution in original post

10 REPLIES 10
xonde
Frequent Visitor

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.

LivioLanzo
Solution Sage
Solution Sage

try with the hasonevalue function

 

=
IF (
    HASONEVALUE ( slicer[header] ),
    SWITCH (
        VALUES ( slicer[header] ),
        "measure1", [measure1],
        "measure2", [measure2]
    ),
    [default measure]
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Anonymous
Not applicable

@LivioLanzoDear Livio, 
thank you for answering, but I'm afraid I didn't understand what should I do exactly? 
So what do you mean by slicer[header]?? 

And should I write this as a measure and then add in as my Slicer field? 

Thank you for your help 

Hi @Anonymous,

 

For your error, I need to know more about your data sample.

 

If it is convenient, could you share a dummy pbix file which can reproduce the scenario, so that we can help further investigate on it? You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.)

 

In addition, do you want to set the default slicer value? If it is, you could refer to this blog.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-piga-msft

I am using AdventureWorksDW data samples. 
You can find the report in the attachment
I thank you in advance for your help 

Hi @Anonymous,

 

Based on your sample, I found that the issue is caused by the measure Final Selection your created. 

 

If you use values function it will return mutiple values which will cause this error.

 

Please modify your measure like below to have a try.

 

Final Selection = SWITCH(TRUE(), 
    SELECTEDVALUE(Selection[Option])= "Sales", [Total Internet Sale],
    SELECTEDVALUE(Selection[Option])= "Profits", [Total Internet Profit], 0)

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-piga-msft
Thank you so much. I can't believe this could have been solved so easily !!!Smiley Indifferent

This is exactly the equivalent for the :

Option Select =
IF (
    HASONEVALUE ( Selection[Option] ),
    VALUES ( Selection[Option] ),
    MAX ( InternetSales[SalesAmount] )
)

 

Thank you for your clever answer 

Hello @Anonymous

 

I am assuming you're  using a small table listing the name of the measures that are displayed as you change the slicer selection. 

What is your final measure that is linked to the slicer selection?

 

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Anonymous
Not applicable

@LivioLanzo yes I have created a simple table with only my options in it, as follow: 

Q7.png

 

And add the option column as field value for the slicer 

Prabhu_MDU
Advocate I
Advocate I

Hi @Anonymous, 

 

In Power BI, Microsort has given in-built features for few action items which we do manually. One of them is the default selection. in your case, you can do as per the below to make the slicer default. 

 

1) select the Slicer you want to add default

2) in the visualization page, select Format 

3) Click on the "Lock Aspect" so that this option will be turn as "On" (by default this option set to be "Off")

 

that's all.. by default whenever the report loaded (Initially) in the browser, the option which you were choosed will be the default value. 

 

Hope this help you.. 

 

Thanks, 

Prabhu

 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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