Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Chart Line Color based on Dimension Value

Hello,

I have a Line Chart which shows monthly values for various brands. The dimensions are Month and BrandName.
Each BrandName creates a line over the months.

I would like to have fixed line colors by brand, i.e. I want to define Brand A = black (RGB(0,0,0)), Brand B = red, etc.
I have a table which deliveres BrandName and BrandColor.

BrandColor contains a text(!) which represents the RGB formula, e.g. "RGB(0,0,0)".

I use the the BackgroundColor property of my Expression to set the color by formula: =$(=BrandColor)

This works fine when I select a specfic BrandName, i.e. the line color changes to the defned BrandColor.
But when no BrandName is selected (which is the desired case, as I want to do a brand comparison), the 'trick' does not work.

Any idea what to look at?
Thanks in advance,
Thilo

PS: Defining the 18 color values and trying to ensure that the BrandNames somehow fit into the right line number does not sound as good solution to me, although I experimented in that direction. If you have a working solution utilizing the Color-Formulas rather than the Background property, I do not mind.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I think I recall needing to specify the RGB values separately:

Brand,BrandRed,BrandGreen,BrandBlue
Brand A, 0, 0, 0
Brand B, 255, 0, 0
...

And then:

=rgb(BrandRed,BrandGreen,BrandBlue)

Edit: And I'm going to guess that the reason your current approach isn't working is that the dollar sign expansion is probably happening BEFORE it gets down to looking at a single row. If so, then at that point, you'd probably get null returned for the color expression.

View solution in original post

4 Replies
Miguel_Angel_Baeyens

Hello,

Have you tried cheking "Persistent Colors" in the "Colors" tab of your chart? It may save you some time.

Regards.

Not applicable
Author

Hello Miguel,

yes - I checked that, but either it just doesn't do what I want, or I do not uderstand it.

I understand 'persistent colors' as a feature, where (in my case) Brands keep the same color, no matter whether I selected 5 or 10 Brands.
This is just partially what I need.

I also need to define a way to define, that Brand A is always black, Brand B is always red, etc.
This color definition is loaded together with the data and may change, whenever 'somebody outside the QV Designer group' thinks it is necessary.

Any idea?
Thanks,
Thilo

johnw
Champion III
Champion III

I think I recall needing to specify the RGB values separately:

Brand,BrandRed,BrandGreen,BrandBlue
Brand A, 0, 0, 0
Brand B, 255, 0, 0
...

And then:

=rgb(BrandRed,BrandGreen,BrandBlue)

Edit: And I'm going to guess that the reason your current approach isn't working is that the dollar sign expansion is probably happening BEFORE it gets down to looking at a single row. If so, then at that point, you'd probably get null returned for the color expression.

Not applicable
Author

Hello John,

Great! That worked!

Thank you,
Thilo