The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello Experts,
I am stuck with something that I guess is not too complex but I am not able to figure out.
Basically, I have bar chart where I want to colour bars conditionally.
So, what I want to happen is
(a) Colour for State Level should always stay Green
(b) Pink colour should be applied to whatever has been selected in Organisation slicer.
Problem :
I thought that I would solve it just through selected value but because in my barchart I have turned off interaction from Organisation slicers to ensure all organisations are diplayed on the chat - it doesn't recognise the single selection in selected value - hope it make sense.
it would be great if anyone can assist.
I am attaching Power BI file - file has 2 tabs - one with the original data and one with the example where I have hardcoded colours to show what I am trying to achieve.
Thanks
Solved! Go to Solution.
Hi @SuryaDave
You can use disconected table of organization , and keep the visual interactions.
+ this tablle will be the source for the slicer :
For the color you can use a DAX with the wanted color HEXA codes ( i used names of colors just to show the logic) :
Color =
if (SELECTEDVALUE(Sheet1[Organisation])= "State Level", "Green",
IF(SELECTEDVALUE(Sheet1[Organisation]) IN( VALUES(Organization[Organisation])),"Pink", "Grey" ))
Result :
The pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Hi @SuryaDave
You can use the method of "play role relationship".
Create a inactive relationship without your table and organizations :
For other visualizations that need to be filtered you can use the "Userelationship" function to make the relationship active .
Like :
The updated pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Hi @SuryaDave,
Thank you for reaching out to the Microsoft fabric community forum. I reproduced the scenario, and it worked on my end. I used my sample data and successfully implemented it.
I am also including .pbix file for your better understanding, please have a look into it:
Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.
Thank you for using the Microsoft Community Forum.
Hi @SuryaDave,
Just checking in to see if the issue has been resolved on your end. If the earlier suggestions helped, that’s great to hear! And if you’re still facing challenges, feel free to share more details happy to assist further.
Thank you.
Hi, no it has not resolved yet ..
@Ashish_Mathur requested for more information that I shared yesterday ....so I waiting for his response & hopefully with his expertise I might get suggestion that can help in resolving my query / question ....
Hi @SuryaDave,
Thank you for posting your query in Microsoft Fabric Community Forum. Also, thanks to @Ritaf1983, @burakkaragoz, for those inputs on this thread.
Has your issue been resolved? If the response provided by the community members @Ritaf1983, @burakkaragoz, addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.
Thank you.
Hi @SuryaDave
You can use disconected table of organization , and keep the visual interactions.
+ this tablle will be the source for the slicer :
For the color you can use a DAX with the wanted color HEXA codes ( i used names of colors just to show the logic) :
Color =
if (SELECTEDVALUE(Sheet1[Organisation])= "State Level", "Green",
IF(SELECTEDVALUE(Sheet1[Organisation]) IN( VALUES(Organization[Organisation])),"Pink", "Grey" ))
Result :
The pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Hi @Ritaf1983 I had a look at your solution & it is doing exactly what I described as my problem. However, what I realised is, I forgot to mention in my post that in my real world problem scenario - the "organisation" slicers is actually being used to filter other charts.
In the solution that you suggested, "organisation" slicers is being used to dynamically change the colour instead of filtering / slicing organisation.
Do you have any other suggestion / solution that can achieve both ? I mean a slicer that can filter organisation as well as bar chart changing colour based on selected value in that "organisation" slicer ?
Thanks
Hi @SuryaDave
You can use the method of "play role relationship".
Create a inactive relationship without your table and organizations :
For other visualizations that need to be filtered you can use the "Userelationship" function to make the relationship active .
Like :
The updated pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Awesome !! Thanks
Happy to help 💌
Hi,
Because of the disconnected what is it that you want to do but are unable to do?
hi @Ashish_Mathur - thanks for your response and question ...
So, basically, in comparing it with my real world scenario, assume that I have few product categories for each city, so that organisation slicer will also filter another chart which has products listed.
So, that orgnisation slicer selection should change colour of bar chart and also same filter should also filter another to only display products for the city that has been selected through organisation slicer - hope that makes sense ...
Hi,
Share the download link of the powerBI file with a 2 visual set up and via a text box, just narrate the requirement there.
Hi Ashish,
Apologies for late response - was travelling
Please see attached updated PBI file with tab explanation that shows the problem statement and solution that I am trying to work out - hope this will give you better clarity ...
thanks again ...
Surya
This will have to be done with a disconnected table.
thanks Ashish for response & again appreciate you sparing time to share your expertise.
I will just accept answer of Rita as official solution as Rita was the first person suggesting the same solution.
hi @Ashish_Mathur sure - will do it in about next 6 hours - really appreciate your response
Thanks @Ritaf1983 for your response - I will surely try it out and get back to you.
Hi @SuryaDave ,
Since you have slicer interactions turned off for the bar chart, you need a different approach to detect the selected organisation. Here's the solution:
Create this measure for conditional coloring:
Bar Color = VAR SelectedOrgs = CALCULATETABLE( VALUES('Sheet1'[Organisation]), REMOVEFILTERS('Sheet1'[Metric Name]) ) VAR SelectedOrgCount = COUNTROWS(SelectedOrgs) VAR CurrentOrg = MAX('Sheet1'[Organisation]) RETURN SWITCH( TRUE(), CurrentOrg = "State Level", "#00B050", // Always green for State Level SelectedOrgCount = 1 && CurrentOrg IN SelectedOrgs, "#FF69B4", // Pink for selected org "#808080" // Grey for others )
How to apply it:
This should work because CALCULATETABLE with REMOVEFILTERS will detect the slicer selection even when visual interactions are turned off.
Let me know if this works for you!
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was assisted by AI for translation and formatting purposes.
@burakkaragoz appreciate your prompt response however, somehow it is not working.
It highlights state level in green and all other city bar - are pink. So, it seems like the formula is not correctly picking up selectedvalue
Let me know if you want me send you the PBI file ?