Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
kaushi2020
Creator II
Creator II

Color by expression

I am using below expression se set colors for my bar chart. 

 

 

Measure expression for color:

if(WildMatch(SkillsetName,'*HH*'), RGB(0, 32, 74),
if(WildMatch(SkillsetName,'*H*'), RGB(50, 136, 189),
if(WildMatch(SkillsetName,'*M*'), RGB(169, 204, 227),
if(WildMatch(SkillsetName,'*L*'), RGB(245, 183, 177),
RGB(250, 219, 216)))))

 

Bars Expression:

=if(WildMatch(SkillsetName,'*HH*'), 'High High',
if(WildMatch(SkillsetName,'*H*'), 'High',
if(WildMatch(SkillsetName,'*M*'),'Medium',
if(WildMatch(SkillsetName,'*L*'),'Low',
'Others'))))

 

here i am not able to see colors based on the expression. can anyone please suggest what i am missing here.

 

thanks in advance.

Labels (1)
1 Solution

Accepted Solutions
justISO
Specialist
Specialist

Try another approach: first, convert your bars expression (=if(WildMatch(SkillsetName,'*HH*'), 'High High',...) to Master Item (as dimension). In master item properties set color Values for each dimension manually. You'll need to convert your RGB code to HEX:

justISO_0-1696499921690.png

Now create this bar chart as 'Bars' using your Master Item dimension, and under 'Colors and legend' set color to 'Custom' by your 'bars expression' dimension:

justISO_1-1696500069495.png

View solution in original post

5 Replies
justISO
Specialist
Specialist

Hi, can it be that you missing comparison part with each WildMatch?, f.e.

if(WildMatch(SkillsetName,'*HH*')>0, RGB(0, 32, 74),
if(WildMatch(SkillsetName,'*H*')>0, RGB...

kaushi2020
Creator II
Creator II
Author

Thanks for your reply. I tried replacing with below.

=if(WildMatch(SkillsetName,'*HH*')>0, RGB(0, 32, 74),
if(WildMatch(SkillsetName,'*H*')>0, RGB(50, 136, 189),
if(WildMatch(SkillsetName,'*M*')>0, RGB(169, 204, 227),
if(WildMatch(SkillsetName,'*L*')>0, RGB(245, 183, 177),
RGB(250, 219, 216)))))

Below is how it looks post updating.

kaushi2020_0-1696496641003.png

 

The default ones is like below:  also I want to keep the Legend as well. How this can be done ? 

kaushi2020_1-1696496714746.png

thanks 

 

 

pallavi_96
Partner - Contributor III
Partner - Contributor III

Hi,

I hope the solution below is effective for you.

you can simply use the code below to add a final dimension to the script component. When you have a finished field, you can make a master dimension and give the values in that field the color of your choice.

if(WildMatch(SkillsetName,'*HH*'), 'High High',
if(WildMatch(SkillsetName,'*H*'), 'High',
if(WildMatch(SkillsetName,'*M*'),'Medium',
if(WildMatch(SkillsetName,'*L*'),'Low',
'Others')))) as SkillsetName

After that, you can utilize that field as a secondary dimension in the dimension section.

pallavi_96_0-1696499473797.png

 

justISO
Specialist
Specialist

Try another approach: first, convert your bars expression (=if(WildMatch(SkillsetName,'*HH*'), 'High High',...) to Master Item (as dimension). In master item properties set color Values for each dimension manually. You'll need to convert your RGB code to HEX:

justISO_0-1696499921690.png

Now create this bar chart as 'Bars' using your Master Item dimension, and under 'Colors and legend' set color to 'Custom' by your 'bars expression' dimension:

justISO_1-1696500069495.png

kaushi2020
Creator II
Creator II
Author

This is ideal solution in my scenario i think. I never explored the color property where these conditions were visible and we can set custom hex codes for each dimension label. Thanks a lot 🙂