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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Community Champion
Community Champion

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors