Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
jmclaren
Contributor III
Contributor III

Change row background color in Qlik Sense table when dimension changes

Hi,

I want to change the background colour in rows of a QS straight table when the main sort dimension value changes - something like this:

jmclaren_0-1627634554307.png

It doesn't really matter what colour it changes to, I just want to make it easier to read/separate the different order groups. I'm guessing this will involve using 'peek' ?? Thanks.

Labels (1)
1 Solution

Accepted Solutions
micheledenardi
Specialist II
Specialist II

Below solution works, but you must be sure that MapPalette contains at least the same number of different colors per each distinct SalesID

MapPalette:
Mapping
Load * Inline [
RecID;RgbColor
1;RGB(0,0,0)
2;RGB(255,255,255)
3;RGB(255,0,0)
4;RGB(0,255,0)
5;RGB(0,0,255)
6;RGB(255,255,0)
7;RGB(0,255,255)
8;RGB(255,0,255)
9;RGB(192,192,192)
10;RGB(128,128,128)
11;RGB(128,0,0)
12;RGB(128,128,0)
13;RGB(0,128,0)
14;RGB(128,0,128)
15;RGB(0,128,128)
16;RGB(0,0,128)
] (delimiter is ';' ) ;

Data_TMP:
NoConcatenate
load * inline [
SalesID,SalesLine,Qty
S1000,1,25
S1000,2,6
S1000,5,12
S1005,3,27
S1005,4,16
S1008,1,4
S1008,2,21
S1008,3,47
];

DistinctSalesID:
NoConcatenate
Load Distinct
	SalesID
Resident Data_TMP;

MapColor:
Mapping
Load
	SalesID,
	ApplyMap('MapPalette',RecNo()) as [RGB Color]	
Resident DistinctSalesID;
Drop Table DistinctSalesID;

Final:
Load *,
	ApplyMap('MapColor',SalesID) as [RGB Color]	
Resident Data_TMP;
Drop Table Data_TMP;

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
micheledenardi
Specialist II
Specialist II

You can achieve that by specifying a background color expression in all Dimensions and Measuers of your chart:

2021-07-30 11_38_37-Window.png

if(SalesID='S1000',rgb(255, 230, 153),
if(SalesID='S1005',rgb(180, 198, 231),
if(SalesID='S1008',rgb(198, 224, 180))))

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
jmclaren
Contributor III
Contributor III
Author

Thanks for the suggestion @micheledenardi . However, the salesID is changing all the time, so I'm not able to hard-code it in that manner. When a salesID changes from the one on the previous row, it needs to trigger a change in the background colour of all rows using the new salesID. This could happen 20+ times in the table. The colour it changes to could be random, but preferably not too close to the previous colour. ..

 
micheledenardi
Specialist II
Specialist II

Below solution works, but you must be sure that MapPalette contains at least the same number of different colors per each distinct SalesID

MapPalette:
Mapping
Load * Inline [
RecID;RgbColor
1;RGB(0,0,0)
2;RGB(255,255,255)
3;RGB(255,0,0)
4;RGB(0,255,0)
5;RGB(0,0,255)
6;RGB(255,255,0)
7;RGB(0,255,255)
8;RGB(255,0,255)
9;RGB(192,192,192)
10;RGB(128,128,128)
11;RGB(128,0,0)
12;RGB(128,128,0)
13;RGB(0,128,0)
14;RGB(128,0,128)
15;RGB(0,128,128)
16;RGB(0,0,128)
] (delimiter is ';' ) ;

Data_TMP:
NoConcatenate
load * inline [
SalesID,SalesLine,Qty
S1000,1,25
S1000,2,6
S1000,5,12
S1005,3,27
S1005,4,16
S1008,1,4
S1008,2,21
S1008,3,47
];

DistinctSalesID:
NoConcatenate
Load Distinct
	SalesID
Resident Data_TMP;

MapColor:
Mapping
Load
	SalesID,
	ApplyMap('MapPalette',RecNo()) as [RGB Color]	
Resident DistinctSalesID;
Drop Table DistinctSalesID;

Final:
Load *,
	ApplyMap('MapColor',SalesID) as [RGB Color]	
Resident Data_TMP;
Drop Table Data_TMP;

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
jmclaren
Contributor III
Contributor III
Author

That works perfectly - many thanks!