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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Fusilier2
Helper V
Helper V

Dynamic bar color

Hope somebody can help with this?

I have a slicer and a clustered bar chart.

 

The slicer shows a list of departments and the bar chart shows the results for each department of a survey question.

 

Capture 1.PNG

 

Capture 2.PNG

 

 

 

Is there any way of formatting the bar chart so that the color of a bar will change color if its corresponding value is selected in the slicer? So for example here,  as Adult Services is selected, it's bar color wil change color to red:

capture 3.PNG

 

but if Finace and audit were selected its color would change to red.

capture 4.PNG

 

 

 

 

Capture5.PNG

1 ACCEPTED SOLUTION

Using the same disconnected table but with the logic in the measure reversed

Disconnected Total Revenue = 
CALCULATE (
    [Total Revenue],
    TREATAS ( VALUES ( 'Disconnected Category'[Category] ), Category[Category] )
)

Disconnected Conditional Bar Color = 
IF (
    SELECTEDVALUE ( 'Disconnected Category'[Category]  )
        IN VALUES ( Category[Category] )
            && ISFILTERED ( Category  ),
    "red"
)

danextian_0-1754051351929.gif

Please see the attached pbix





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

12 REPLIES 12
Fusilier2
Helper V
Helper V

Thanks for your responses, very helpful and I can get it working if I add in a separated table, however the existing slicer is currently used to filter other visuals on the page so I would need a solution that uses the existing slicer.

I can't upload my pbix file due to org data security.

Using the same disconnected table but with the logic in the measure reversed

Disconnected Total Revenue = 
CALCULATE (
    [Total Revenue],
    TREATAS ( VALUES ( 'Disconnected Category'[Category] ), Category[Category] )
)

Disconnected Conditional Bar Color = 
IF (
    SELECTEDVALUE ( 'Disconnected Category'[Category]  )
        IN VALUES ( Category[Category] )
            && ISFILTERED ( Category  ),
    "red"
)

danextian_0-1754051351929.gif

Please see the attached pbix





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you so, much. Seems to be working fine.

@danextian very good

 

I did not notice that the customer was ok with hiding the not selected items in the slicer in the below table. 

 

Very good solution!

with your existig slicer it is impossible to obtain what you are asking as that will filter automatically the value you select

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Ah, OK. Thanks for responding.

You are welcome, pls mark as a solution and kudos if you believe anybody deserves it

 

so others can easily find the answers and possible solutions

 

Thx

danextian
Super User
Super User

Have you even validated your response before posting it?

Why are you telling OP to create a field parameter table by adding all the deparment fields. It is clear in the screenshots that the departments are in a single column? And even if you meant measures by fields, why would you have OP to unnecessarily create one for each distinct department? And what's with those extra responses?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello @danextian,

The response you commented on has been removed for being inaccurate. 

 

Best,

Natalie H.

Community Manager

danextian
Super User
Super User

Hi @Fusilier2 

You’ll want to use a disconnected table for the categories. If you use the same table (or one that's related), selecting something like "Finance & Services" will filter the bar chart to just that one category. With a disconnected table, you avoid that and can still apply conditional formatting using a measure that refers to it.

danextian_0-1754042566003.png

 

Please see the attached sample pbix. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
FBergamaschi
Solution Sage
Solution Sage

It is possible but you need to create a separated table to make this work

 

Can you share the pbix via some cloud service? Otherwise I give you a path to follow

 

If this helped, please consider giving kudos and mark as a solution

@mein replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Here is the path

 

1 create a new table

 

Selection = ALLNOBLANKROW ( Table[column] )

 

where Table[Column] is the column where you have the values "Finance and audit", etc

 

Leave the new table disconnected ftomr the model

 

2 create the following measure

 

Selection Color =
IF (
           SELECTEDVALUE( Table[column] ) =
           SELECTEDVALUE( Selection[column]),
           "Red",
           "Blue"
)
 
3 use the above measure to conditionally format your bars
 
FBergamaschi_0-1754042622502.png

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.