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

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

7 REPLIES 7
Samarth_18
Super User
Super User

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

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

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

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

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.

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

BINGO.

Thanks Buddy.

Anonymous
Not applicable

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
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.