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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
JK_PBI
New Member

Change data slicer background color if any values (instead of all) is selected

Hi,

 

I am using the default standard data slicer on my report. I have a request from user to change data slicer background color if one or more values of slicer (instead of all) is selected.  I thought slicer's visual background conditional formatting can do the magic but unfortunately it doesn't.  It seems when slicer data is selected, the selection does not apply to slicer itself.

 

Does anyone have any workaround?  Thanks in advance;

 

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@JK_PBI although there is a hack (work around) to achieve this:

 

- add a shape and set the background of this based on the measure given below

- make sure this shape is under the slicer

- turn off background color under size and style on format pane of slicer (see below)

 

parry2k_0-1700542464430.png

 

here is the measure you can use to set the background color of the shape:

 

Color = 
VAR __TotalCount = COUNTROWS ( ALL ( Orders[City] ) )
VAR __SelectedCount = COUNTROWS ( ALLSELECTED ( Orders[City] ) )
RETURN
IF ( __TotalCount <> __SelectedCount, "Red" )  --set the color hex code here I just set it to red for demo

 

and here is the outcome:

 

2023-11-20_21-00-17.gif

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@JK_PBI although there is a hack (work around) to achieve this:

 

- add a shape and set the background of this based on the measure given below

- make sure this shape is under the slicer

- turn off background color under size and style on format pane of slicer (see below)

 

parry2k_0-1700542464430.png

 

here is the measure you can use to set the background color of the shape:

 

Color = 
VAR __TotalCount = COUNTROWS ( ALL ( Orders[City] ) )
VAR __SelectedCount = COUNTROWS ( ALLSELECTED ( Orders[City] ) )
RETURN
IF ( __TotalCount <> __SelectedCount, "Red" )  --set the color hex code here I just set it to red for demo

 

and here is the outcome:

 

2023-11-20_21-00-17.gif

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you for the workaround. Appreciate!

parry2k
Super User
Super User

@JK_PBI at this point you cannot set the background color dynamically, in other words, it is not possible for now.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

JK_PBI
New Member

@Ritaf1983  thanks for the response.

 

This is what I am after:

 

For this Week Slicer,  if all options are selected,  no backgrund colour (white)

 

JK_PBI_0-1700541507074.png

 

if one or more values are selected, show background in red color

 

JK_PBI_1-1700541566021.png

 

 

 

 

 

 

 

 

Hi @JK_PBI 
@parry2k suggested great solution 🙂

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @JK_PBI 
Can you please show the screenshot with the desired result?

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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