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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Thathayoyo
Contributor III
Contributor III

Table: Color a row based on the value of a column

Hello,

I have a table whose rows I am looking to color according to the textual value in ColumnC (see exemple below). If I have 3 possible values ​​in ColumnC then I would have 3 colors. I cannot know before which values ​​that will be in the ColumnC (it depends on the data) therefore this color assignment must be somehow dynamic. How to do it?

 

Thanks.

 

Thathayoyo_0-1731078346699.png

 

1 Solution

Accepted Solutions
Qrishna
Master
Master

Dynamic Random coloring:

Data:
LOAD *,
//AutoNumber(ColC, 'ColorID') as ColorID,
RGB((AutoNumber(ColC, 'ColorID') * 85) , (AutoNumber(ColC, 'ColorID') * 170) , (AutoNumber(ColC, 'ColorID') * 255) ) as Random_Color
// color(fieldindex(ColC, 'ABXX12')) as random_color
INLINE [
ColA, ColB, ColC
zderf, 12, ABXX12
sdesf, 0, SDZE23
hfdrjjnct, 134, ABXX12
sarthv, 125, QSX23
dmllrto, 35, SDZE23
];

 

UI:under all dims and measure, color: =only(Random_Color)

_X.PNG

Usually we maintain a seperate excel for color codes and formats, in case you have one, you have to map them o the data and proceed as above.

View solution in original post

4 Replies
Qrishna
Master
Master

=pick(match(ColC, 'ABXX12', 'SDZE23','QSX23' ), rgb(125,125,0), blue(), red()) //put your own color codes in place

Try to use this expression for each dimension and measure background.

Thathayoyo
Contributor III
Contributor III
Author

Thanks. My problem is that 'ABXX12', 'SDZE23','QSX23' are examples but the values ​​in ColumnC will change each time depending on the user's selection. I'm looking for a generic way to be able to assign as many colors as there are values ​​in this ColumnC.

Qrishna
Master
Master

Dynamic Random coloring:

Data:
LOAD *,
//AutoNumber(ColC, 'ColorID') as ColorID,
RGB((AutoNumber(ColC, 'ColorID') * 85) , (AutoNumber(ColC, 'ColorID') * 170) , (AutoNumber(ColC, 'ColorID') * 255) ) as Random_Color
// color(fieldindex(ColC, 'ABXX12')) as random_color
INLINE [
ColA, ColB, ColC
zderf, 12, ABXX12
sdesf, 0, SDZE23
hfdrjjnct, 134, ABXX12
sarthv, 125, QSX23
dmllrto, 35, SDZE23
];

 

UI:under all dims and measure, color: =only(Random_Color)

_X.PNG

Usually we maintain a seperate excel for color codes and formats, in case you have one, you have to map them o the data and proceed as above.

Qrishna
Master
Master

I have posted generic/dynamic coloring code too.