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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Json file to define the hexadecimal color of the categories of a data column

Hello,

 

Does anyone know if it is possible to define the hexadecimal color of the categories of a data column in the theme json file?

 

Thanks.

1 ACCEPTED SOLUTION

Hi @Anonymous Power BI does not directly support defining hexadecimal colors for individual categories within a data column using the theme JSON file.But you can achieve the similar effect by creating measure.

 

example: as i have given to you with switch or if sttements you can follow:

 

FruitColor =
SWITCH (
TRUE (),
'Table'[Fruit] = "Peach", "#FFFFFF", // White for Peach
'Table'[Fruit] = "Strawberry", "#17563B", // Dark green for Strawberry
"#000000" // Default color (black)
)

 

you can replace table and column name as per your convinence.Set the data color property of the visual to use the FruitColor measure.

 

Hope this approach helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
rajendraongole1
Super User
Super User

Hi @Anonymous  In your theme JSON file, define a custom color palette with the hexadecimal colors you want to use. For example:

 

{
"name": "Custom Theme",
"dataColors": ["#FF5733", "#33FF57", "#5733FF", "#CCCCCC"]
}

 

you can also use the customize theme options at view>> customize Current Theme option. 

 

rajendraongole1_0-1717411630315.png

 

 

Hope it helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Anonymous
Not applicable

Hello rajendraongole1, thanks for your reply, but I need to define the color by category value of a column.

 

For example, if I have the "Fruit" column, I would like to know if there is a way through the json file to indicate that I want "Peach" to be the hexadecimal code #FFFFFF, the "Strawberry" fruit to be #17563B, ...

 

Thanks.

Hi @Anonymous Power BI does not directly support defining hexadecimal colors for individual categories within a data column using the theme JSON file.But you can achieve the similar effect by creating measure.

 

example: as i have given to you with switch or if sttements you can follow:

 

FruitColor =
SWITCH (
TRUE (),
'Table'[Fruit] = "Peach", "#FFFFFF", // White for Peach
'Table'[Fruit] = "Strawberry", "#17563B", // Dark green for Strawberry
"#000000" // Default color (black)
)

 

you can replace table and column name as per your convinence.Set the data color property of the visual to use the FruitColor measure.

 

Hope this approach helps

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors