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, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JD09
Advocate I
Advocate I

New Button Slicer (November 2023 Update)- Conditional Formatting

Hello,
Can we achieve Conditional color formatting for the Button / Tile in the new button Slicer (November 2023 Update).
I want to have Button / Tile with different backgroung color based on the conditions. Please find reference screenshot .
Thank you in Advance!!

JD09_0-1700742314886.png

 

15 REPLIES 15
Gazzer
Resolver II
Resolver II

I was having the same (or at least a similar) issue and eventually found a solution. I'm not sure if it is exactly what you were having, but I thought it might be worth sharing.

 

All I wanted to do was to have buttons dimmed if clicking them would return no records.

The two key things were that my measure needed to return a zero instead of null/blank, plus the colour representing >0 in my count needed to not be too close to white (#FFFFFF). If the colour was white or very close to it, all the buttons adopted the same colour regardless of value - I assume this is a bug.

 

I made a simple measure to do the count - Category is the field displayed on the slicer:

Category Count = 
COUNT(Testing[Category]) + 0

SlicerFill = 
SWITCH(
   [Category Count],
   0,  "#EFECE9",
   "#FEFEFE"
)

I assume you could use a simple IF() instead of the SWITCH() but I was playing around with more options for colour based on a scale of counts, so I already switch in play. 
The measure with the  +0 gives you this when something in my Testing table has been selected that only has on Category value:

Gazzer_0-1718201088730.png

This way we get all the buttons, all the time. 

Gazzer_1-1718201160418.png

I created several measures so as to be able to format borders, text and fill colour when selected, but the above principle remains the same. Add the measure under Field Value to the appropriate state/object.

Bob_Creamer
Frequent Visitor

Me too.
I want a slicer where the user chooses Red, Blue, Green, etc and so the button fill should have those colours.

I can get the Value font colour to match using the fx conditional formula linked to a measure.
I can get the Label text to read as the colour code and the Label font colour to match
But the Button Fill conditional format just wants to give one colour for all (6) buttons.

Seems like a glitch and I am surprised it is not fixed (using Feb 24 update).

For now I will try the image route

Hello, @Bob_Creamer , 
Alternative to this, I have also used the Image functionality, setting Image as a backgroung. Reference screenshot attached.

JD09_0-1711426084766.png

Thank You!!

I can get .jpg images to work on my button slicer
But I can't get my real second choice - .svg images to work.
No idea why but I am assuming it is the same limitation with Fill colour linked to a measure.

sanjeewauom
Helper I
Helper I

Same here. Tried with so many measures but only one color is there for all buttons. Sadly have to use a workaround.

Think this is a serious value adding feature that needs to be considered.

 

 

Sarchiz
Frequent Visitor

You can try this easy workarounds:

 

1.for different colors when button is selected - create  shape with desired color for selected value, place on top of desired button,format-> send to back , then formating->change background to 100% transparency and also callout background of selected to 100% transparency. This way on button select you ll have the color from the shape underneath.

 

2.If you need different colors on selected and on default: create text box to mimic the button (font, size)  and the desired color , put it on top of button slicer ,then ,  make a bookmark to show hide text object; next and add a button on top of  slicer button same size , set it to 100% transparency , no borders and assign the bookmark. This way you have an aditional color (on default state) but you loose color change when hovering over ... 

 

At least like this you have some solution until maybe this is fixed and your visual is still based on slicers .

tcbassett
Frequent Visitor

Hey, I was trying to get this to work too using measures.

 

My theory is nothing is selected in the button slicer so cannot set the value based on selection.

For example:

1. I use a simple measure to set the fill colour when selected.  This works as not based on selecting an actual button value.

Simple Measure = "#0022BB"
tcbassett_0-1705362139106.png

 

2. Now try a measure based on selecting a value.

IF(SELECTEDVALUE(Slicer[Region]) = "Brisbane Region" , "#0022BB")
tcbassett_1-1705362388187.png
 
hmm, doesn't work.  But if I filter the button slicer visual based on the region in the measure to "Brisbane Region"
tcbassett_2-1705362510119.png

 It works!!!!

tcbassett_3-1705362530030.png

 

So I just have to filter the slicer to change the button colour to apply conditional formatting ;).

 

I have tried different options i.e. hasonevalue, but I guess the thing with that button is it isn't actually being filtered to one value to enable setting to a colour.  Also tried switching based on values but just set to the last colour in the statement.

 

Missing something with the dax.

Hi @tcbassett ,
Thanks for the Revert!!
Have tried this approach, It Only return the HEX Code, but it does not fill the Button as required.

Sorry @JD09 wasn't posting as a fix.  I think this is a bug with the new slicer button.  Just showing what I tried and didn't work for me.  Same issue as when you tried the conditional formatting based on a column - always sets to the first value as nothing is selected on a button.  

 

My work around was to use an image.  I couldn't get a complete fill but I'm using the coloured dot in place of legend on the graph.  Good enough for me.

 

tcbassett_0-1705383221914.png

 

It's a similar measure to what I tried for the fill but it actually works to switch the image??

 

This video shows switching the images if it helps.  NEW Button Slicers in Power BI | 3 Examples You Don’t Want to Miss! - YouTube  

 

 

JD09
Advocate I
Advocate I

Hi @v-yiruan-msft ,
Version Used: Power BI Desktop - November 2023,
For Sample Data - Refer Image-1,
Fields applied  - ID
Approaches Tried for Conditional Formatting - Refer Image - 2 ,
Problem - It fills the single Color to all the Buttons in the slicer..

JD09_0-1701321303052.png 

JD09_1-1701321561887.png

 

Thank you!!

picander
Advocate I
Advocate I

Hi! 

 

This topic is of high-relevance. I expected as well the New "Button Slicer" to have individual conditional formatting options on the buttons, but it appears NOT to be the case - I am affraid (let's hope it is not the case).

 

The conditional formatting works, but is applied to all buttons, and not individually per button based on e.g. First Field Value (or even a Measure). I tried hard, also not only on Fill but the other options (Shadow, etc.) - no chance.

This is quite disappointing, if it designed so. Let's hope this is a temporary problem, and the new slicer can soon provide such functionality! Otherwise, I am affraid a lot of us will still stick with dirty workarounds (Treemap...).

 

In general, Power BI is badly missing real "conditional formatting" options... While it is now provided on a lot of formatting elements, and it goes in the right direction, it is not available on some of the most important elements: Clustered Bar Charts (with a few exception of "single measure") and line charts. Every line color in most cases has to be carefully manually selected... when you have dozens of pages, this is such a burden.

 

Currently playing with other dirty workarounds - images can be individually / dynamically assigned per button... but base64-harded coded colored images as button fill as measure hopefully is not a necessary workaround...

 

Let's hope for the best, hopefully there is a solution!

miTutorials
Super User
Super User

Yes, the Fill section under Buttons has conditional formatting option, please try that.

 

miTutorials_0-1700745265929.png

 

Thanks for the response, have tried the same but , it givies the single Color. Reference screenshot attached.

JD09_0-1700798998855.png

 

Hi @JD09 ,

Thanks for reaching out to us with your problem. Base on your description, it seems that it doesn't work when configure conditional formatting on Fill color for the new slicer. In order to make troubleshooting, could you please provide the following info? It would be helpful to find the solution. Thank you.

  • What's the version of your Power BI Desktop?
  • Could you please provide some sample data in your table?
  • Which field you are applying on the new slicer?
  • How did you configure conditional formatting? What's the setting logic? Is the field [Color] the one which applied on the new slicer?vyiruanmsft_0-1701165225036.png

Best Regards

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

Hi,

 

I'm facing the same issue, I cannot conditionally format individual buttons, which does not make any sense. So many features in this visual but not the basics.

Thank you.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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