Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

stacked bar chart - define colours

Hi,

Does anyone know how to define colours for each segment of a stacked bar chart?

Thanks,

D

1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

Re: stacked bar chart - define colours

Sorry, forgot to mention that for the stacked bars you'll have to change the background color for the expression, not the dimension. You can use the same pick/match expression though


talk is cheap, supply exceeds demand

View solution in original post

9 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Re: stacked bar chart - define colours

If you expand the plus of a dimension (Used Dimension) or expression you'll see an option Background color. You can change the definition and add an expression to select a color. Green() will select green, Red() red, rgb(1F,1F,1F) a grey.


talk is cheap, supply exceeds demand
Highlighted
Not applicable

Re: stacked bar chart - define colours

I found the option you mentioned but I don't know where to type the expression as "settings for Selected Dimention" are greyed out (not active).

Highlighted
Not applicable

Re: stacked bar chart - define colours

Would it have to be IF statement defining colours for each segment of the dimension?

e.g. =if(Medium='Referral Traffic',RGB(139,14,215),if(Medium='Direct Traffic',RGB(13,145,21)))

where Medium is the Dimension with two segments: Direct Traffic and Referral Traffic

Highlighted
MVP & Luminary
MVP & Luminary

Re: stacked bar chart - define colours

If you have only two values, one if statement will do:

=if(Medium='Referral Traffic',RGB(139,14,215),RGB(13,145,21))

If you have more values then the pick and match functions can be used.

If you have a LOT of values add a field in the table that holds the color values.

There's also a color(n) function that returns a predefined color for n between 0 and 255


talk is cheap, supply exceeds demand
Highlighted
Not applicable

Re: stacked bar chart - define colours

I have four segments so I need to use Pick and Match functions I guess.

Could you please apply this to the above example?

Highlighted
MVP & Luminary
MVP & Luminary

Re: stacked bar chart - define colours

=pick(match(Medium, 'Referral Traffic', 'Direct Traffic', ...etc), RGB(139,14,215), RGB(13, 145, 21), ...etc)


talk is cheap, supply exceeds demand
Highlighted
Not applicable

Re: stacked bar chart - define colours

for some reasons it doesn't do anything when I apply the statement

at least I know how to use pick and match functions 😉

Thanks

Highlighted
MVP & Luminary
MVP & Luminary

Re: stacked bar chart - define colours

Sorry, forgot to mention that for the stacked bars you'll have to change the background color for the expression, not the dimension. You can use the same pick/match expression though


talk is cheap, supply exceeds demand

View solution in original post

Highlighted
Not applicable

Re: stacked bar chart - define colours

Yep that was the key for it to work.

Perfect. Thanks a lot Mr