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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
NickTrent32
Advocate II
Advocate II

Set Conditional Formatting Colors Using JSON Theme

During the July 2019 Power BI Desktop update, Amanda Cofsky mentioned that conditional formatting colors could be set using a JSON theme file. She mentions it around the 5:20 mark of this video: https://youtu.be/l7OMRUF9UYg?t=320

 

Does anyone have the correct code that I could use to add this to my JSON theme?

1 ACCEPTED SOLUTION

The September 2019 Power BI Desktop update video had a spot that finally showed the correct syntax to do this!

 

"maximum": "#00b050",
"center": "#ffff00",
"minimum": "#c00000",

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Based on newer updates -

pbi.PNGpbi_2.PNG

You can set the diverging colors by customising your current theme. Once set, they are your default colors

 

dax
Community Support
Community Support

Hi NickTrent32,

The code in video is correct, you could copy code like below in notepad, then save this as json file, and import this in powerbi, it should work

{
        "name": "St Patricks Day",
        "icons": {
            "test":{
                "url":"https://i.gifer.com/Omjx.gif",
                 "description":"test" }
                    }
    }

209.PNG

 Or you also could use gif in conditional format icon directly without importing it. You could try to use measure like below (use this directly by referring to its link)

Icon Set Measure = 
SWITCH (
    TRUE (),
    [% Change vs Prior Year]  < 0, "data&colon;image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='100' height='100' viewBox='0 0 100 100'> <circle cx='50' cy='50' r='40'  stroke='purple' stroke-width='4' fill='purple' /> </svg>",
    [% Change vs Prior Year] < 0.4, "data&colon;image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='100' height='100' viewBox='0 0 100 100'> <circle cx='50' cy='50' r='40' stroke='green' stroke-width='4' fill='yellow' />
</svg>",
    "https://i.gifer.com/4Ym4.gif"
   --  "https://i.gifer.com/Omjx.gif"
)

You could refer to Conditional Formatting Using Icons In Power BI for details.

Best Regards,
Zoe Zhi

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

 

Sorry @dax , I should have been more clear. I would like to set the default Minimum, Center, and Maximum colors in the screenshot below using a JSON theme.

 

Is that possible?

 

Screenshot.png

Hi NickTrent32,

At first, we  can't use custom icon whe you set color conditional format. If you want to set custom color theme, you could try below json

 

{
        "name": "St Patricks Day",
        "dataColors": ["#568410", "#3A6108", "#70A322", "#915203", "#D79A12", "#bb7711", "#114400", "#aacc66"],
        "background":"#FFFFFF",
        "foreground": "#3A6108",
        "tableAccent": "#568410"
    }

Then you will get below result

215.PNG

If you want to set custom icon based on condition, you could use JSON to import this in report like my irst reply sample, then use this liek below

 

216.PNG

Or you don't need to import cutsom icon by json, you could use this directly. You could create measure like below

Measure 2 = 
SWITCH (
    TRUE (),
    [Measure 3]<=5, "https://i.gifer.com/Omjx.gif",
    [Measure 3] <10, "https://i.gifer.com/KhAg.gif" ,
    "https://i.gifer.com/4Ym4.gif"
   --  "https://i.gifer.com/Omjx.gif"
)

 

You could see coresponding image information in above meaurse, then set cinditional icon like below

 

217.PNG

Best Regards,
Zoe Zhi

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

Apologies again if I'm not being clear, @dax. This question/request do not have anything to do with icons. The reason I mentioned the video is because during that video, while talking about using JSON for icons, Amanda seems to also mention that a JSON theme could be used to set Conditional Formatting colors.

 

I am already using a JSON theme to apply a new color scheme for my organization. What I would like to do is also use that JSON theme to change the default default Minimum, Center, and Maximum colors.

 

In fact, those colors do not even inherit the color scheme I am applying through a JSON them.

Hi NickTrent32,

Did you try above sample for color theme, then import this to report? when you import this in report, you could choose corresponding color

222.PNG

Or you could click on custom colr to type corresponding color to set color(which might not inherit the theme color)

223.PNG

Best Regards,
Zoe Zhi

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

Hi @dax  - Yes, I understand that I can manually select a color from a color palette set by a them for the Minimum, Center, and Maximum colors or type in a hex code.

 

My question is, can I set those Minimum, Center, and Maximum colors using a JSON theme, rather than having to manually select the color from a color palette each time? Also, the colors I want to select are different than the colors I have set in my color palette.

The September 2019 Power BI Desktop update video had a spot that finally showed the correct syntax to do this!

 

"maximum": "#00b050",
"center": "#ffff00",
"minimum": "#c00000",

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.