cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
utsavlexmark
Helper III
Helper III

Change color based on rule

Hello,

I am using some "Cards" in the dashboard. These cards are showing some percentages. Now I want to change the colors based on a range of percentage.

Such as;

1. If it is <15% color will be RED.

2. If it is 15%-20% color will be ORANGE.

3. If it is >20% color will be GREEN.

I am trying to customize it from "Format" (Under visualization)>Color(under data level). I trying with "Color Scale" and "Rule" options, but not working.

Can anyone guide me please.

Regards

Utsav

1 ACCEPTED SOLUTION

It looks you have converted [open rate] as percentage from ribbon like below:-

Samarth_18_0-1627632807836.png

You can update your color format code with below:-

color_format =
IF (
    ( [active_accounts] * 100 ) < 15,
    "red",
    IF (
        ( [active_accounts] * 100 ) > 15
            && ( [active_accounts] * 100 ) < 20,
        "orange",
        IF ( ( [active_accounts] * 100 ) > 20, "green" )
    )
)

Samarth_18_1-1627632970791.png

 

 

View solution in original post

7 REPLIES 7
Samarth_18
Solution Sage
Solution Sage

Hi @utsavlexmark 

You need to create a measure with below code and use it in background color as field value.

color_format = 
if(
[active_accounts]<15,"red",
    if([active_accounts]>15 && [active_accounts]<20,"orange",
        IF([active_accounts]>20,"green")))

Note:- Pass your required column which you bringing on card in place of [active_accounts]

Now in click on fx icon in backgroud of visual format pane

Samarth_18_0-1627630104409.png

 

Select format by field value and select newly created measure

Samarth_18_1-1627630205482.png

You will see below as output:-

Samarth_18_2-1627630234015.png

Thanks,

Samarth

color_format =
if([Open Rate]<15,"red",
if([Open Rate]>15 && [Open Rate]<20,"blue",
IF([Open Rate]>20,"green")))
This is the code I have used for the mesure. But even if the open rate is 18.3%, it is showing red.

It looks you have converted [open rate] as percentage from ribbon like below:-

Samarth_18_0-1627632807836.png

You can update your color format code with below:-

color_format =
IF (
    ( [active_accounts] * 100 ) < 15,
    "red",
    IF (
        ( [active_accounts] * 100 ) > 15
            && ( [active_accounts] * 100 ) < 20,
        "orange",
        IF ( ( [active_accounts] * 100 ) > 20, "green" )
    )
)

Samarth_18_1-1627632970791.png

 

 

View solution in original post

Just a question, out of curiocity. Suppose I have 3 - 4 other fileds like that and I want to apply sme rule for them, but the values will be different from this one.

Can I create some other color format codes with different name and use those in same way?

Regards

Utsav

Yes you can do in this way.

BINGO.

Thanks Buddy.

alekhved
Resolver II
Resolver II

hi @utsavlexmark 

 

It appears that you are looking at the right place to format the color. Without looking at data or calculation, it would be difficult to suggest. If it's not sensitive data, please share the PBIX file.

 

Thanks!

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!