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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
HPS1RT
Frequent Visitor

Power BI table colour coding based on other visual

Hello Community,

I have column chart and table in one report page. Is there a possibilty to display the colour coding in the table based on colour of that text value in other visual?

HPS1RT_0-1712129569971.png


Thank you in advance:)

3 ACCEPTED SOLUTIONS
StrategicSavvy
Resolver II
Resolver II

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:

StrategicSavvy_1-1712131189737.png

 

 

StrategicSavvy_0-1712131171501.png

 

 

Hope it helps!

View solution in original post

Ritaf1983
Super User
Super User

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")
Ritaf1983_0-1712131417096.png

or for graph :

Ritaf1983_1-1712131487333.png

pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

7 REPLIES 7
StrategicSavvy
Resolver II
Resolver II

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!

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?

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)

StrategicSavvy_0-1712152868250.png

 

Add your vote to this idea: Microsoft Idea which is about adding this functionality.

 

All the best!

 

Ritaf1983
Super User
Super User

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")
Ritaf1983_0-1712131417096.png

or for graph :

Ritaf1983_1-1712131487333.png

pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
StrategicSavvy
Resolver II
Resolver II

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:

StrategicSavvy_1-1712131189737.png

 

 

StrategicSavvy_0-1712131171501.png

 

 

Hope it helps!

Hello @StrategicSavvy , @Ritaf1983 
Thank you for your reply.
Sorry I forgot to mention. I have "n" number of categories and I cannot define the colors to each of it. 
can we make it something more dynamic such that categories in the table takes the color based on category color in column chart?
Thank you:)

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.