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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
paulmorgan
Helper II
Helper II

Highlight a specific bar based on slicer selection

Hi

 

I implemented a suggestion found here in the forums. I must be doing something wrong. It's not working.

 

I have a chart that lists some values for each country in a region. In the example, it's Latin America. I want to highlight Brazil by coloring it red, while keeping the other values grey.

 

Based on the example I've seen, I did the following:

1) Created a separate and disconnected table ("tableCountry") of just the countries that form the y-axis of the chart ("Lists[Country]") ;

2) Created a slicer with the countries from "tableCountry"

3) Created a measure as follows: 

colorFocus = IF( MAX ( Lists[Country] ) = SELECTEDVALUE( tableCountry[Country] ),"Red","Grey")
4) Create a conditional formatting for the Data Colors in the chart using "Field Value" Based on field: "colorFocus"
 
The bars are all grey. If I select Brazil, it doesn't color that bar Red. 
 
Any guidance would be most appreciated.
 
1 ACCEPTED SOLUTION

@paulmorgan 

Just checked out your sample file. The problem is that the country names in the 'tableCountry' table don't match the country names in the 'Lists' table (probably an extra space at the end or something)

I Just created a new table to check it out using DISTINCT and you get this:
correct.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

9 REPLIES 9
Beinexpowerbi
Advocate I
Advocate I

hi @powerbi-learner we have created a solution to this using dax .

 

Please check our latest blog on this :

https://www.beinex.com/blog/dynamic-highlight-bar-chart-with-slicer/

 

 

PaulDBrown
Community Champion
Community Champion

@paulmorgan 

See if this thread helps:

Change the colour of a bar based on a filter 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@paulmorgan , This seems correct to me

Try this. Just sure country names are matching

colorFocus = IF( MAX ( Lists[Country] ) in  allselected(tableCountry[Country] ),"Red","Grey")

 

I am assuming List is name of column, that is used on x-axis

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Thanks very much for your suggestion. Unfortunately, it didn't work for me. I created a sample file, but I guess I don't "rank" being able to upload pbix files, and my company doesn't allow for people outside the company to access OneDrive files, and I don't have a Dropbox account. I tried uploading to Google Drive, but it gives me basically a "file structure" when I click on it instead of an actual pbix file. 

 

If you have any other suggestions on how to share the file, let me know. Regardless, I do appreciate your willingness to help out!

@paulmorgan 

Google Drive is fine (even though you "see" a file structure, if you download you get the PBIX file). Alternatively, try a file transfer service such as:

Wetransfer 

Btw, did you check out the suggested thread ?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi Paul. Thanks for the advice. Here is the link to the Google Drive file. Hopefully, that works.

 

Yes, I was starting to work through the thread. it looks like it could be good. It's just more involved, and i was hoping to get away with being lazy. 😉  But I'm grabbing some coffee and working through it. 

 

Thanks for your efforts!

 

Paul

@paulmorgan 

Just checked out your sample file. The problem is that the country names in the 'tableCountry' table don't match the country names in the 'Lists' table (probably an extra space at the end or something)

I Just created a new table to check it out using DISTINCT and you get this:
correct.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






For some reason I needed to delete the slicer and create a new one. Then things started working as you outlined. Thanks very much for your help.

This is really embarrassing. haha.  I double-checked the names, and they match exactly. But I tried the approach anyway, and I still can't get it to work. Would you maybe share the file you created? I must still be doing something just silly wrong. Thanks for you persistence!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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