Discussion board where members can get started with QlikView.
Does anyone know how to define colours for each segment of a stacked bar chart?
Go to Solution.
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
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.
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).
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
If you have only two values, one if statement will do:
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
I have four segments so I need to use Pick and Match functions I guess.
Could you please apply this to the above example?
=pick(match(Medium, 'Referral Traffic', 'Direct Traffic', ...etc), RGB(139,14,215), RGB(13, 145, 21), ...etc)
for some reasons it doesn't do anything when I apply the statement
at least I know how to use pick and match functions ;-)
Yep that was the key for it to work.
Perfect. Thanks a lot Mr