Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Randomly colored bars together with forced colored bars

Hi all,

In Qlik Sense, I would like to force one bar in my bar chart to be dark blue, another one to be light blue, and I would like the rest to be randomly colored according to the 12 color scheme.

So far, I've been able to color the chart using the following expression which makes account CLIPPER dark blue and account GREENTEA light blue:

if (Account = 'CLIPPER',RGB(51,34,136),if(Account = 'GREENTEA',RGB(136,204,238),))

The problem is that the other accounts remain grey, while I want them to be in the same colors as if I selected coloring by dimension with the 12 color scheme.

I could mention all of my accounts in the expression, but adding a new account would mean that its bar would be grey again and the formula has to be adapted every time a new account is added.

Does anyone know a good solution?

Thanks for your help!

1 Solution

Accepted Solutions

Re: Randomly colored bars together with forced colored bars

Try this:

if (Account = 'CLIPPER',RGB(51,34,136),if(Account = 'GREENTEA',RGB(136,204,238),color(FieldIndex('Account',Account))))

4 Replies

Re: Randomly colored bars together with forced colored bars

Try this:

if (Account = 'CLIPPER',RGB(51,34,136),if(Account = 'GREENTEA',RGB(136,204,238),color(FieldIndex('Account',Account))))

Not applicable

Re: Randomly colored bars together with forced colored bars

That's what I was looking for! Many thanks!

Not applicable

Re: Randomly colored bars together with forced colored bars

It appears that my "Show Legend" option has disappeared after using colors by expression. Do you know how to combine colors by expression and the option to include the legend?

Thanks in advance.

Re: Randomly colored bars together with forced colored bars

Sorry, no idea.