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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Analitika
Post Prodigy
Post Prodigy

Button dynamic color in Power BI

Hello,

 

Please help me to make that whenever I press on button it changes color. I have two buttons sale1 sale2. Default is selected sale1 If I select sale2 then color changes of sale1 and sale2 buttons. How I could achieve this?

5 REPLIES 5
mdaatifraza5556
Super User
Super User

Hi @Analitika 

If i am not wrong.

I am assuming you have two measure sales1 and sales2.


1. Create a field parameter


Screenshot 2025-08-19 125147.png

 

Change the slicer into tile


2. Use the below dax for the result 

Selected Sales =
SWITCH(
    SELECTEDVALUE(Parameter[Parameter Order]),
    0, [Sales1],
    1, [Sales2]
)


Result

 


Screenshot 2025-08-19 130033.png

 


Screenshot 2025-08-19 130038.png

 

IF this answers your questions, kindly accept it as a solution and give kudos.

I am not using slicer but two buttons.

Hi @Analitika 

Can you please try the below steps.

1. Just Add two bookmark
       a. Sales1

       b. Sales2

 

Screenshot 2025-08-19 171134.png

 

2. Now Go to insert and select Bookmark navigator.

 

Screenshot 2025-08-19 171144.png

 

 

Here is your result.

 

Screenshot 2025-08-19 171211.png

 

Screenshot 2025-08-19 171217.png

 


You can adjust your background as per your preference using Format navigator


 

If this answers your questions, kindly accept it as a solution and give kudos.

rohit1991
Super User
Super User

Hi @Analitika 

Could you please follow below steps:

 

Add buttons

  • Insert >> Buttons >> Blank >> rename to Sale1_off (grey style).

  • Duplicate it >> rename to Sale1_on (give it your selected color, e.g., brown).

  • Do the same for Sale2 >>  Sale2_off (grey) and Sale2_on (brown).

  • Put the two “on” buttons exactly over the “off” ones (same position/size).

  • Go to view >> Bookmark >> Create 4 Bookmarks
  • Go to view >> selection >> Rename every button for easy understanding.

image.png

 

 

Selecitons:

  1. Go to View >>Selection.

  2. In the Bookmarks pane, select Sales 1 off.

  3. In the Selection pane, hide Sales 2 on and Sales 1 off (click the eye icons).

  4. Go back to the Bookmarks pane, right-click Sales 1 off.

  5. In the menu, uncheck Data (so only Display/Current page are ticked).

  6. Click Update.

 

image.png

 

2. For Sales 2 off

  1. Stay in View >> Selection.

  2. In Bookmarks pane, select Sales 2 off.

  3. In the Selection pane, hide Sales 1 on and Sales 2 off.

  4. Right-click Sales 2 off in the Bookmarks pane >> uncheck Data >> click Update.

image.png

 

Apply Action on Sales 1 off button

image.png

 

 

Apply Action on Sales 2 off button

image.png

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
jaineshp
Solution Sage
Solution Sage

Hey @Analitika,

Looking for a way to create dynamic button colors in Power BI? Here's a practical solution that works:

Solution Steps:

1. Create a Measure for Button State

 

Selected Button =
IF(SELECTEDVALUE('ButtonTable'[ButtonName]) = "Sale1", "Sale1", "Sale2")

 

2. Set Up Button Actions

  • Create a simple table with button names (Sale1, Sale2)
  • Each button should filter this table to show the selected button

3. Dynamic Color Formatting

  • Go to button formatting options
  • Use conditional formatting for fill color
  • Create a measure like:

 

Button Color =
IF([Selected Button] = "Sale1",
IF(MAX('ButtonTable'[ButtonName]) = "Sale1", "#0078D4", "#F3F2F1"),
IF(MAX('ButtonTable'[ButtonName]) = "Sale2", "#0078D4", "#F3F2F1"))

 

4. Apply to Both Buttons

  • Set both buttons to use the same color measure
  • Configure button actions to update the selection
  • Test the toggle behavior

Pro Tips:

  • Use bookmark actions instead of table filters for smoother transitions
  • Consider using variables in your DAX for better performance
  • Keep your color codes consistent with your report theme

This approach gives you the toggle effect you're looking for without complex workarounds. The buttons will automatically switch colors based on selection state.

 

Fixed? ✓ Mark it • Share it • Help others!


Best Regards,
Jainesh Poojara | Power BI Developer

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors