Forum Discussion
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.
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:
but if Finace and audit were selected its color would change to red.
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" )Please see the attached pbix
12 Replies
- danextianSuper 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.
Please see the attached sample pbix.
- danextianSuper 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?
- Natalie_iTalentAdministrator
Hello danextian,
The response you commented on has been removed for being inaccurate.
Best,
Natalie H.
Community Manager
- FBergamaschiSuper User
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
- FBergamaschiSuper User
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 barsIf 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
- Fusilier2Helper 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.
- FBergamaschiSuper User
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
- Fusilier2Helper V
Ah, OK. Thanks for responding.
- danextianSuper User
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" )Please see the attached pbix
- FBergamaschiSuper User
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!