Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Color by Expression

Hello Folks!

Question. I have a bar chart (see below). I currently have them sorted by the measure of highest % to lowest %. I want the highest % bar (regardless of the percent) to be green then a slow fade to yellow for the mid bar and slow fade to red to the lowest bar. I want them to match the style of my gauge (see below).

Any ideas how to write this expression? Let me know if more information is needed. Thanks!

Bar Chart - Green fade to yellow fade to red

Theme I want the bars to match ^

Dimensions = [BC]

Measure = Count({$<[LEVEL 0 COMPLETION]={"Y"},[LEVEL 1 COMPLETION]={"Y"},[LEVEL 3 COMPLETION]={"Y"}>}SID)/Count(SID)

1 Solution

Accepted Solutions
brunobertels
Master
Master

Hi Lauren

use this in your color by mesure panel :

color by expression :

ColorMix2( (rank(total column(1))/(noofrows(TOTAL)/2))-1 ,green(), yellow(),lightred())


Tips : you can set variable for colors so that if you use this color formula in several charts and want to change colors , you just have to change the variable rather than change manually all the color mesures

Hope it helps

View solution in original post

4 Replies
brunobertels
Master
Master

Hi Lauren

use this in your color by mesure panel :

color by expression :

ColorMix2( (rank(total column(1))/(noofrows(TOTAL)/2))-1 ,green(), yellow(),lightred())


Tips : you can set variable for colors so that if you use this color formula in several charts and want to change colors , you just have to change the variable rather than change manually all the color mesures

Hope it helps

Not applicable
Author

Hi Bruno! Thanks for the reply! This is what I got below with that expression. I need the yellow in the middle and red at the end. Please advise.

Not applicable
Author

I fixed it!

expression - ColorMix2( (rank(total column(1))/(noofrows(TOTAL)/2))-1 ,green(), lightred(),yellow()) <---- I rearranged the color order - not sure why this works but it works! Thanks!

brunobertels
Master
Master

Hi Lauren

Glad to read it works

for further information about this color theme approch see this post :

https://community.qlik.com/docs/DOC-14760

and this one

https://community.qlik.com/docs/DOC-16046

regards