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
Saidi
New Member

conditional formatting histogram bar chart

I come to you for technical support if possible. I would like to do conditional formatting on a histogram visual (Bar chart)

- I have a slicer that displays the list of regions in the country (each region contains several cities)

- the visual in question is a histogram that displays all the cities of the country.

- my question is how to make conditional formatting only for the cities belonging to the region selected by the slicer.

Thanks in advance

MFC_histograme.png

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Saidi 

 

Create a calculated table(Slicer) summarizing regions and cities, then create a slicer using the summarized region field instead of the region field of the main table.
Then create a measure as follows:

 

_color = 
var _condition=IF(MAX('Table'[Value])>5,"Green","pink")

var _isSelected=MAX('Table'[City]) in SUMMARIZE(ALLSELECTED('Slicer'),[City])

var _notSelected="#E6E6E6"

var _if=IF(_isSelected,_condition,_notSelected)
return _if

 

Result:

vangzhengmsft_0-1631774735216.png

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-angzheng-msft
Community Support
Community Support

Hi, @Saidi 

 

Create a calculated table(Slicer) summarizing regions and cities, then create a slicer using the summarized region field instead of the region field of the main table.
Then create a measure as follows:

 

_color = 
var _condition=IF(MAX('Table'[Value])>5,"Green","pink")

var _isSelected=MAX('Table'[City]) in SUMMARIZE(ALLSELECTED('Slicer'),[City])

var _notSelected="#E6E6E6"

var _if=IF(_isSelected,_condition,_notSelected)
return _if

 

Result:

vangzhengmsft_0-1631774735216.png

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Saidi , For that region need to be independent slicer , measure not joined to the table

 

Then you need to create a measure and use that in conditional formatting using field value option

 

Switch( True() ,

max(region[region]) in allselected(slicer[region]) , "green" else "red")

 

refer, if needed

How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.