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

Alternate colour in table based on value

I would like to alternate the colours in a table based on the first column which contains a number as these lines belong logically together.

Pty

Col2

Col3

2

2

3

9

9

12

12

12

33

The background colour should be alternating between two colours to indicate which rows belong together.

So even/odd row is not working. Checking, if the previous row has another value than the current value using Above(field,1) does not work, because I need to toggle between two colours and cannot take a color based on the check.

Any idea how I can solve this problem?

Thanks

7 Replies
Not applicable
Author

Hi Blappurs,

sorry to bother you.

Could you tell me how did you color alternative rows by using even/odd concept? did you use any Extension for this?

Not applicable
Author

Alternate colouring can be achieved for columns using a background expression:

  if(Even(RowNo(TOTAL)), rgb(219,219,219), rgb(255,255,255))

(background expression is only available for "Measure" columns in QlikSense).

As said before, this does not help in my case.

Regards

Urs

Not applicable
Author

At first, Thank you for your reply.

Exactly, It applies to only Measures column, Not for dimensions in Pivot table. Even in Table view we don't have a option to provide background color for dimesnsions.

Thank you for your time.

Not applicable
Author

I think we can solve your issue by defining the colors at script and assigning them in UI Level. I attached sample application for you.

Hope it helps.

Not applicable
Author

Thanks for your time.

This does not work in my case, because the a certain row might be missing due to a different selection, but the coloring should still be alternating. In my example table, I cannot assign a colour to a value (example 9 = grey), because another selection might make row value 3 not appear and then the value 9 should be coloured white because it would adjust to 2 which is already grey. I need a mechanism like:

  if ((Above(col1,1)<> col1), toggleColor(), keepColor())

But how can I implement this in QlikSense?

JTSmall
Contributor II
Contributor II

In lieu of creating a completely new post, I'm bumping this as I have the exact same use-case. 

Wondering if anyone has come up with a solution since 2015... 

My thought is that you could rank([TheID]) with a simple whole number, incrementing by 1, and then use the Even(RowNum()) method, utilizing the rank, to change the color. However, Rank, in Qlik Sense, is not as cooperative as I would like it to be and I cannot figure out how to create a simple whole number rank, starting at 1, and incrementing by 1... 

Rank color alternation.PNG

Any thoughts on how to make this work?  

Thanks.

YangLi
Contributor
Contributor

Same challenge here.

I know Rnk can be created as calculated dimension 'RnK' = aggr(rank(Pty),Pty). However it gets weird when applying color to it: if(even(RnK),'red','green'). The color coding is not always following the ranking.

Waiting for more expertise here~