I’m trying to have dynamic color for stacked in stacked colum chart based on legends in PowerBI.
For example: I have quantity for X-axis, Y-axis with two values:
Component1: Consumer, Corporate, and Home Office
Component2: Technology, Furniture, and Office Supplies
and legend with Sub-Category: Accesories, Appliances, Art, Blinders, Bookcases,…
My expectation is to have dynamic color for stacked based on the value of the legend
For instance, If the legend (sub-category) is “Accessories”, the color for the stacked in the stacked column should be Red, “Appliances” should be Blue…
I couldn’t create a measure or even apply condition formatting (fx) for this chart. Is it because I have so many dimensions and fields for this chart?
Try to create a mapping table for your sub-categories :
ColorMapping =
DATATABLE (
"Sub-Category", STRING,
"Color", STRING,
{
{"Accessories", "#FF0000"}, // Red
{"Appliances", "#0000FF"}, // Blue
{"Art", "#FFFF00"}, // Yellow
{"Binders", "#00FF00"}, // Green
{"Bookcases", "#FFA500"} // Orange
}
)
Then ceate a relationship between your main table and the ColorMapping table using the Sub-Category and create a measure based on the color column :
SubCategoryColor =
RELATED(ColorMapping[Color])
In the format pane in your visual try to use the measure in the color option under the bar section.
2