Forum Discussion
Power BI table colour coding based on other visual
- 2 years ago
Hi HPS1RT
Yes , it is possible. If you want to have control over specific colors over bars you can add new dimension to your table that will map category with color.
Then you can use conditional formatting in Matrix/Table or Column Char that will format colors based on Field Value based on Column including Hexidecimal/Color name.
See the example below:
Hope it helps!
- 2 years ago
Hi HPS1RT
You can create Dax with color coding and use a created measure for all the visuals.
For example :color = SWITCH(SELECTEDVALUE('Table'[category]),"a","red","b","blue","c", "#3f007d")or for graph :
pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
- 2 years ago
Hi HPS1RT
No, this can work only with Dax we don't have the functionality of coloring visuals based on other visuals, so you have to have some logic to get the colors.If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Hi HPS1RT
You can add new calculated column to your dim (categories) and use this syntax:
RandomColor =
VAR cR =
RANDBETWEEN (0, 255 )
VAR cG =
RANDBETWEEN (0, 255 )
VAR cB =
RANDBETWEEN ( 0, 255 )
VAR RedP0 =
MOD ( cR, 16 )
VAR RedP1 =
MOD ( INT ( cR / 16 ), 16 )
VAR GreenP0 =
MOD ( cG, 16 )
VAR GreenP1 =
MOD ( INT ( cG / 16 ), 16 )
VAR BlueP0 =
MOD ( cB, 16 )
VAR BlueP1 =
MOD ( INT ( cB / 16 ), 16 )
VAR hexTable =
ADDCOLUMNS (
{ RedP1, RedP0, GreenP1, GreenP0, BlueP1, BlueP0 },
"Hex", SWITCH (
[Value],
10, "A",
11, "B",
12, "C",
13, "D",
14, "E",
15, "F",
[Value]
)
)
RETURN
"#" & CONCATENATEX ( hexTable, [Hex], "" )
Something similar was presented here:
Solved: Create calculated column in DAX for random hex col... - Microsoft Fabric Community
Hope it helps!
- HPS1RT2 years agoFrequent Visitor
Hello StrategicSavvy
Thats wonderful. Thank you for your answer.
Actually if I use the stacked column chart, then I don't have option for conditional formatting. Any idea how to tackle this?- StrategicSavvy2 years agoResolver II
I think currenly there is no option to dynamically adjust color for legend in stacked bar chart. Here is similar problem:
Solved: Changing colours of legends - Microsoft Fabric Community
I would suggest to use only bar and slice by month (not ideal but synced)
Add your vote to this idea: Microsoft Idea which is about adding this functionality.
All the best!