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

How do I set conditional colors for a chart based on Y-value?

I am charting survey results (see image below). I want to maintain the color scheme below (green for best to red for worst). The issue is that some results sets are so small that there could be only 1 response, and if that is 'Never' then it appears as Green since that's the first color in my scheme.

How can I use conditional formatting so that 'Always' is set to Green, 'Never' is set to Red, etc?

All the examples I've seen here for conditional colors seem to be based on the values (count or sum).

Thanks

QV_chart.jpg

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Durgampudi,

You can do it by setting the background color of your expression. Please see the following image for reference:

foto.png

In this example, I have multiple status a case can go through, so in order to keep the same color for each status, I added an expression in the background option. This expression evaluates the state of the current row and returns that color that it should have.

Hope it helps.

Regards,

-- Karla

View solution in original post

10 Replies
Anonymous
Not applicable
Author

Hi Durgampudi,

You can do it by setting the background color of your expression. Please see the following image for reference:

foto.png

In this example, I have multiple status a case can go through, so in order to keep the same color for each status, I added an expression in the background option. This expression evaluates the state of the current row and returns that color that it should have.

Hope it helps.

Regards,

-- Karla

jonathandienst
Partner - Champion III
Partner - Champion III

Is his a dimension, or a collection of expressions? If its the latter, you could use persistent option on the Colors tab to lock the color to a particular expression. If it is a dimension, then go with the above option.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
kkkumar82
Specialist III
Specialist III

Are the values of that dimension are fixed like what you have in the bar graph,

then create a inline load

as below

Load * Inline [

YourxaxisDimension, Color

Always,RGB(0,255,0)

Never, RGB(255,0,0)

...

...

];


Load * Inline [

YourxaxisDimension, Red,Green,Blue

Always,0,255,0

Never, 255,0,0

...

...

];


After that goto the chart and expression, background and add

=RgB(Red,Green,Blue)

Please attached sample where I have fixed two colors for Always and Never

Hope it helps

You can also try one more option in the colors tab i.e. Persistant, but some how that doesn't work all times.

Not applicable
Author

Hi Karla,

Thanks, what you've shown seems to be what I need, but for some reason my expression is not having the expected effect.

I don't have a syntax error. Do you see what I may be doing wrong below?

Thanks

QV_chart2.jpg

Anonymous
Not applicable
Author

Hi Naren,

So far, I don't see any error in your expression, could you please share a sample qvw so I could check it.

Regards,

-- Karla

Not applicable
Author

Hi Karla,

QVW is attached. Thanks so much for looking into this!

~ Naren

kkkumar82
Specialist III
Specialist III

Hi Naren,

can you add a '=' symbol before pick and check

kkkumar82
Specialist III
Specialist III

Also

I see "F. "  is missing for Never.

Please check attached file

Anonymous
Not applicable
Author

Hi Naren,

I've checked the expression, and so far I only found a typo mistake, you have Never instead of F. Never. And the green color for Always and Mostly look very similar, maybe you could change the tone. I'm sending you the QVW back, adding some different color so you can see the effect.

Hope it helps.

-- Karla