Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
blaise
Partner - Specialist
Partner - Specialist

Color code rows in dimension value

Hello

I would like to color code the background of the dimension values in a straight table, somewhat like the "strip every" function but for every new value. With the following example table;

Dimension1Dimension2Expression
A1
A2
A3
B1
B2
C1
D1
D2
D3
D4

I would like the background color of Dimension1 to be grey for the values A, white for B, grey for C, white for D and so on.

Is this possible? I have tried with the above() function but that doesn't seems to do the trick. The values of Dimension1 in the real data is not as simple as A-Z.

31 Replies
blaise
Partner - Specialist
Partner - Specialist
Author

I don't want unique color for every value

blaise
Partner - Specialist
Partner - Specialist
Author

It works with no selection, but if you for example select Dim2 = A,C then all rows are grey. I don't think it can be solved in the script.

blaise
Partner - Specialist
Partner - Specialist
Author

I've tried it but sadly it doesn't work. Will try more with the aggr(), match() and concat() function though...

Not applicable

I defined the coulr for each value ofDim1 in the Script. So you selected any thing, automatically selection made.

anlonghi2
Creator II
Creator II

Hi blaise,  please try this:  1. open the table property window 2. select the dimension tab  3. click the plus (+) sign on the left of the dimension to fill with different colour 4. double click on background colour 5. enter your conditional fill expression [eg. =if(Dimension1 like 'A*',QlikTechBlue(),if(Dimension1 like 'B*',QlikTechGray(),Green())) ] 6. confirm changes  Regards Andrea

blaise
Partner - Specialist
Partner - Specialist
Author

doesn't solve my problem. I don't want to hard code colors to each dimensions.

Not applicable

is it possible for you to store the color (RGB combination) as part of your table? If YES, then in your table itself you can define which color you want for each dimension value (A, B, C etc..).

Then you can use the RGB values in your table object to define the color of the cell based on cell value.

thomduvi83
Partner - Contributor III
Partner - Contributor III

Hi Blaise,

My last proposition is working weel i think, see attachement.

3 remarks :

- Don't forget the "=" sign before the variable expression

- if you have "set analysis" in the expressions of your table that could reduce the values of Dim2, use the same SET in the concat function of the variable

- The sort order of Dim2 must be fixed. If it's not sorted alphabeticaly, you can also define a custom sort order in the concat function

Good luck,

Thomas

blaise
Partner - Specialist
Partner - Specialist
Author

Yes indeed, it works!

I would rather not have a variable that is calculated for every selection, but it might be that this is the only available solution .

Thanks for all your help

anlonghi2
Creator II
Creator II

Hi blaise,  try putting the following expression in the color property of the dimension:  =if(Mod(FieldIndex('Dimension1',Dimension1),2)=1,QlikTechGray(),White())  Regards AL