Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Gysbert_Wassenaar

Try this:

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


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

Try this:

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


talk is cheap, supply exceeds demand
Not applicable
Author

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

Not applicable
Author

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.

Gysbert_Wassenaar

Sorry, no idea.


talk is cheap, supply exceeds demand