Forum Discussion

tuomaskb's avatar
tuomaskb
New Member
3 years ago
Solved

Custom cell colors picked from table

It is possible to pick treemap cell colors from a table instead letting PowerBI randomly choose those?

 

My data is color usage, see picture, and it would make much more sense to the users to actually see the colors. I have is separate table colorcode linked to a color rgb values.

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi tuomaskb ,

     

    You can select the visual and manually set the color or add conditional formatting in Color under the Format pane.

    For your scenario, you can create a new measure:

     

    Measure = CALCULATE(MAX('ColourTable'[Colour]),'ColourTable'[Country]=MAX('Table'[Country]))

     

    and use it for the conditional format:

    please check the pbix file.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

5 Replies

  • You need to convert your RGB codes to HEX and then use the below measure.

     

     Color = MAX(Category[Hex Color Code])

     

    Then Apply conditional formatting by  clicking on FX button under colors and choose Field Value as format style  and in the next section select the measure.

     

    Regards

    Ismail

    www.youtube.com/MiTutorials

    There are ~200 Power BI Tutorials on my channel, do check them out!

    • tuomaskb's avatar
      tuomaskb
      New Member

      Thank you, but how do I calculate HEX using DAX?

      • miTutorials's avatar
        miTutorials
        Icon for Super User rankSuper User

        You need to find the hex code for your RGB codes using some website and create a table.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi tuomaskb ,

     

    You can select the visual and manually set the color or add conditional formatting in Color under the Format pane.

    For your scenario, you can create a new measure:

     

    Measure = CALCULATE(MAX('ColourTable'[Colour]),'ColourTable'[Country]=MAX('Table'[Country]))

     

    and use it for the conditional format:

    please check the pbix file.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

    • tuomaskb's avatar
      tuomaskb
      New Member

      This is working, thank you!

       

      Only problem was that I had 5000 colors in a table in rgb(int) format, had to make changes to the database to get rgb in hex format. Apparently DAX doesn't have needed functions to make conversion on PowerBi side.