9 Replies Latest reply: Oct 25, 2012 8:09 AM by Dariusz Szul

# stacked bar chart - define colours

Hi,

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

Thanks,

D

• ###### 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.

• ###### 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).

• ###### 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

• ###### 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

• ###### 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?

• ###### Re: stacked bar chart - define colours

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

• ###### 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

• ###### 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

• ###### Re: stacked bar chart - define colours

Yep that was the key for it to work.

Perfect. Thanks a lot Mr