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 Categories throughout document

Hi Everyone,

I have a field that relates to a category (Cat1, Cat2, Cat3). I want to assign colours (colors) to each of these categories so when I create a chart it already knows the color of each category. Can this be achieved via an inline table or something? With three categories in this field it shouldn't be too difficult, however I can't quite get my head around it.

Any help would be greatly appreciated!

Thanks

Gareth

3 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi,

you can use the if-then-else-statement like this:

Load category,
If(category='Cat1',RGB(255,0,0),
If(category='Cat2',RGB(0,255,0),RGB(0,0,255))) AS Color,
....
From Table;

In your expressions you can use this color in background and/or text color.

Not applicable
Author

Thanks for your response!

What I have is the following inline table:



Colour_table:
LOAD * INLINE [
FEELING, SENT_SORT_ORDER, SENT_COLOUR
Positive, 1, 'RGB(255,0,0)'
Negative, 3, 'RGB(0,255,0)'
Neutral, 2, 'RGB(0,0,255)'
];




I can get the sort order working fine and I can use the colour for the background of a text object as a working example by using the following expression as the background colour:

=$(=SENT_COLOUR)

But when I try and do this on my chart it doesn't work. FEELING is a dimension that is used to stack bars and also in some pie charts. I want these to have a colour assigned to positive/neutral and negative that carries throughout the document.

Any ideas?

Thanks

Gareth

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

If you break the colour code out into the three values for red, green and blue this should work fine:

Colour_table:

LOAD * INLINE [

FEELING, SENT_SORT_ORDER, R,G,B

Positive,1,255,0,0

Negative,3,0,255,0

Neutral, 2,0,0,255

];

Your colour expression is then simply:

=rgb(R,G,B)

Obviously for this to work you will need to ensure that FEELING is a dimension in the chart, or you may have multiple values for each colour part and null will be returned instead.

Hope that helps.

Steve

Quick Intelligence