Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. 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
Not applicable

You can click on the '+' symbol next to your dimension and there under 'background' option, you can write a if statement to derive the color you want.

I hope this helps.

thomduvi83
Partner - Contributor III
Partner - Contributor III

Hi,

This should do the trick :

Background Color expression for Dimension1 :

 

=if(even(aggr(NODISTINCT rowno(),Dimension1)),rgb(180,180,180),white())

Regards,

Thomas

blaise
Partner - Specialist
Partner - Specialist
Author

Yea, I know how to change the background color of the cell - the question I asked was how to give the the Dimension1 value A and C the same bg color, and B and D another bgcolor.

blaise
Partner - Specialist
Partner - Specialist
Author

We're getting close, thanks Thomas. However it looks like i need to combine some sort of sort with the aggr() function, as of now the first set of dimension1 values in the straight table doesn't get the number 1, and the second set of values doesn't get the number 2.

thomduvi83
Partner - Contributor III
Partner - Contributor III

Yes, you're right, rowno() order seems to be inverted (max value for first dimension value).

That's start to become tricky, but i think the following expression could make it :

=if(even(aggr(NODISTINCT GetPossibleCount(Dim1) - rowno(),Dim1)),white(),rgb(180,180,180))

blaise
Partner - Specialist
Partner - Specialist
Author

Well im my test app the "sort order" is somewhat fucked - i could live with an inverted sort order but not with the an "unknown order".

Attached the test app.

thomduvi83
Partner - Contributor III
Partner - Contributor III

Yea, rowno() seems to use kind of fieldindex values, we cannot sort them.

I've changed my mind, so, last try...

With a variable : vTEST = concat(DISTINCT TOTAL {<Dim2-={"$(=null())"}>} chr(39)&Dim2&chr(39),',')     //Need to remove null values, don't know why

and as color expression : =if(even(match(Dim2,$(vTEST))),white(),rgb(200,200,200))

Hope this one will be the good one...

Thomas

Not applicable

Hi Blaise,

There is a function called HSL(Hue,Saturation,lum) where we can pass the values from 0 to 1.

If you are going to generate one unique HSL for each distinct value of Dim1, you can use the value in Background colour.

Here is the sample code that i attached. Please reply back if it works.

Not applicable

Hi Blaise, Please find the attched file and hope it helps very well.