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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
AdamMG
Helper I
Helper I

Stacked Bar Chart sliced by subcategory but coloring by category

Hi everyone.
I need to create a stacked bar chart where data can be sliced by subcategory, but coloring but category.
Normal stacked bar chart will look like this
aaaaaa bbb cc dddddddddd e fffffffffffffff
but
a,d,f will have a red color
b,c,e will have a green color 
etc

I have more than 20 categories and 20 subcategories

3 REPLIES 3
AdamMG
Helper I
Helper I

I can see, this is not possible with PowerBI.
I did it using Python

amitchandak
Super User
Super User

@AdamMG , you can use measure-based conditional formatting for bar ( If no legend and only one measure) and use that in the conditional formatting using the field value option

 

 

example

Measure =
Switch(true(),
max(Table[Column]) = "R1" , "Red" ,
max(Table[Column]) = "R2" , "Green" ,
max(Table[Column]) = "R3" , "Pink "
)

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...
https://amitchandak.medium.com/power-bi-where-is-the-conditional-formatting-option-in-new-format-pan...

 

or

Power BI Customer to Retain, Scatter Quadrant -Segment in 4 quadrants based on Margin % and Discount, Use Constant Line- https://youtu.be/0k_C_E7YOQY

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Your solution will not work with stacked bar chart - sorry

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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