Forum Discussion
Consistent color mapping across visuals in Power BI reports
- 6 months ago
The standard solution for this is a color mapping table + DAX conditional formatting measure, and it scales well across large reports.
Step 1 — Create a color mapping table (either in Power Query or as a calculated table):
CategoryHexColorProduct A#4472C4Product B#ED7D31Product C#A9D18E
Step 2 — Create a DAX measure that looks up the color for the current context:
daxCategory Color =
LOOKUPVALUE(
ColorMapping[HexColor],
ColorMapping[Category],
SELECTEDVALUE('Products'[Category]),
"#BFBFBF" -- default fallback color
)
Step 3 — Apply to each visual via Format → Data colors → fx (conditional formatting) → Field value → select your Category Color measure.
Yes, you still have to wire it up per visual — there's no true global binding in Power BI today — but you only define the colors once in the mapping table. When you need to change Product A's color, you update one row and it flows everywhere automatically.
For cross-report consistency, the cleanest approach is to put the color mapping table in a shared semantic model that all reports connect to. Then every report uses the same source of truth.
Bonus tip: You can also embed the color mappings directly in the report theme JSON under dataColors with named entries, but that approach only works reliably for series order, not specific category-to-color bindings. The DAX measure method is more robust for named categories. - 6 months ago
1) Create a color mapping table
Create a small table that defines the color for each category.
2) Create a color measure
Return the color based on the current category.
Product Color = SELECTEDVALUE ( ProductColorMap[Color] )3) Apply conditional formatting
In each visual:
Format → Data colors → Conditional formatting → Format by: Field value
Select the Product Color measure.
Hi SinghArchana ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Hi Anonymous ,
Thank you for your reply.
I tried the suggested solution and it works well in standard scenarios. However, when using a field parameter in the Legend, I’m unable to see the fx (conditional formatting) option for data colors, so I cannot apply colors based on a measure.
Could you please confirm if conditional formatting is supported when a field parameter is used in the Legend, or if there is any recommended workaround for this scenario?
Thanks in advance!
- Anonymous5 months agoNot applicable
Hi SinghArchana
I tested this scenario with a sample setup and observed that the conditional formatting fx - field value option is still available even when a field parameter is used in the Legend. However, since field parameters dynamically switch the underlying column for example, Product vs Region, a color measure written for one specific field does not automatically adapt when the parameter changes. Because of this, the colors may appear inconsistent or incorrect when switching between fields. So while the feature is available, it is not fully reliable for dynamic legend scenarios driven by field parameters.
At the moment, Power BI does not provide a native way to dynamically bind colors to changing dimensions via field parameters. As a workaround, you may consider using separate visuals for each field or adjusting the logic so that the color measure aligns with each possible field in the parameter.
Thank you.