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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Anonymous
Not applicable

Help with applying multiple specific colours in P.BI Themes using custom .json files

Hey everyone,

 

If have the column Country and then in that clolumn I have France, Germany, England ect how would I do the following in a .json file?

 

For column Country:

France = yellow

England = blue

ect

 

I know there is a custom colour theme creator available so my aim was to use that and then implement this into that.

 

EDIT: Reason being I have 100+ brands and each has their own colour I want to apply this to the theme file so all of my graphs use this colour coding system. I don't fancy applying all of this to each page individually.

 

Any suggestions will be most helpful.

 

Thanks!

1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

My article here covers this. https://exceleratorbi.com.au/conditional-formatting-with-a-text-field-in-power-bi/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

5 REPLIES 5
MattAllington
Community Champion
Community Champion

You cannot set the sort order to align to your data in a theme file.  You could try determining the sort order of your data, and then ordering the colour in your theme file in the same order. You may get lucky



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
MattAllington
Community Champion
Community Champion

My article here covers this. https://exceleratorbi.com.au/conditional-formatting-with-a-text-field-in-power-bi/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

Thank you for suggesting DAX for this over writing in a .json file. I used your idea to have a google and instead of using variables and an if statement I used the following with your method and it worked:

Colourformatting =
SWITCH(
TRUE(),
SELECTEDVALUE(Table[Country]) = "Germany" , "#ff0000",
SELECTEDVALUE(Table[Country]) = "France" , "#ffff99",
SELECTEDVALUE(Table[Country]) = "England", "#ffbf00",
"000000"
)

Great.  For bonus points, you could create a master data table in Excel containing the country name and the HEX code you want to use.  Then load that table and write your measure in such a way that it loads the values from your table. The benefit is that it is easier to maintain.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

Hi Matt, thank you for your response but I am referring to applying a custom theme by importing a .json file so this would not be written in DAX. Reason being I have 100+ brands and each has their own colour I want to apply this to the theme file so all of my graphs use this colour coding system.

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors