Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set fixed color for single values

Hi all,

I'm looking for a solution for the problem that the same selection has a different color in different charts.

My goal is to set a "global color" for every specific value (Value 'A' should always be blue).

An example:

You have 2 pie charts - the first shows value 'A' in red - the second shows value 'A' in blue.

I tried it with a load command:

Load * INLINE [
X,Y,Z,Function
0,2,3,A
200,123,12,B
0,122,232,C
212,121,121,D
124,123,121,E
]
;

then I used "RGB(X,Y,Z)" as background color in the expression.

The described procedure works perfectly but now is the challenge: I try to make that selection dynamic (for example if Selection <> Function it should take another inline as basis for coloring). It seems that the background color function doesn't allow any functions.

When I try =if(Selection='Function',RGB(X,Y,Z),if(Selection='Sector',RGB(A,B,C),...) it always shows the 'else' value. Does anyone have an idea how to solve that issue?

An idea how the color selection could be made dynamically (in reason of changes in the dataset) would be awesome!

Looking forward. Thanks!

Alex

1 Solution

Accepted Solutions
Not applicable
Author

Hey,

thanks for your input. I got it with a mix of "Load * INLINE" in combination with background color of expressions.

Here is how I managed it:

---------------------

Load command:

Load * Inline [

Selection

Function

Sales man

];

Load * Inline [
A,B,C,Function

0,2,3,A
200,123,12,B
0,122,232,C
212,121,121,D
124,123,121,E

];

Load * Inline [
D,E,F,Sales man

120,242,123,ASD
123,231,152,BEAS
0,12,232CEFAS
212,21,121,DASDA
124,3,121,EEAS

];

-----------------------

Background Color in Expression

if(Selection='Function',RGB(A,B,C),
if(Selection='Sales man',RGB(D,E,F).

------------------------

Whenever I select Function, the function 'A' has the same color in every chart (if the background color expression is set).

View solution in original post

8 Replies
crystles
Partner - Creator III
Partner - Creator III

If the formula you are using always uses the "else" then it is not finding the first part of the if statement. I see where you have "Sector" as the 'else'. I don't know where that is coming from in the table?

If the values you want to change color are numbers you can simply set up ranges?

Or if they are specific values, you could simply add a field to the table that has the RGB and whenever that selection is made, it automatically selects the RGB associated with it in the table?

maxgro
MVP
MVP

what's Selection?

If Selection is a field with Function and Sector values it works

If not could you explain?

crystles
Partner - Creator III
Partner - Creator III

Did not mean to confuse you.

I have a document that has buttons, and when selected, these buttons change the value of a variable.

Action in Button = Variable: vButton=1

So to help show the user which button is selected, when the button is selected and the value of the variable changes, then the color of the button changes.

Here is the code that is in the Background Expression of the button.I have the RGB codes as variables so I can easily change the colors, for every button in the group at one time.

=if(Field=1, $(vcButtonBGColor1),$(vcButtonBGColor2))

Does that help it make more sense?

jonas_rezende
Specialist
Specialist

Hi, Alexander Muller.

How did the relationship in the data model with the second InLine?

Could you share with us?

maxgro
MVP
MVP

like this?

see also the attachment

1.png

crystles
Partner - Creator III
Partner - Creator III

Yes, exactly like that. You can use that logic with the variable, just replace the numbers with the Fields you want.

Not applicable
Author

Hey,

thanks for your input. I got it with a mix of "Load * INLINE" in combination with background color of expressions.

Here is how I managed it:

---------------------

Load command:

Load * Inline [

Selection

Function

Sales man

];

Load * Inline [
A,B,C,Function

0,2,3,A
200,123,12,B
0,122,232,C
212,121,121,D
124,123,121,E

];

Load * Inline [
D,E,F,Sales man

120,242,123,ASD
123,231,152,BEAS
0,12,232CEFAS
212,21,121,DASDA
124,3,121,EEAS

];

-----------------------

Background Color in Expression

if(Selection='Function',RGB(A,B,C),
if(Selection='Sales man',RGB(D,E,F).

------------------------

Whenever I select Function, the function 'A' has the same color in every chart (if the background color expression is set).

crystles
Partner - Creator III
Partner - Creator III

Excellent. Glad you were able to get it working.