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: 
Krish
Contributor III
Contributor III

Change Background color of a dimension in Qliksense Pivot table

Hi,

  I have a dimension in pivot table which needs to be have different color codes based on the dimension value. 

Eg:

          If(Country = 'US','RGB(255,0,0)', If(Country = 'EU','RGB(0,255,0,)',RGB(0,0,255)')

The Background color in dimension works only for 1 color code and does not work for multiple if conditions. How can this be achieved.

Labels (1)
19 Replies
ajaykakkar93
Specialist III
Specialist III

Hi,

I used Pick Wildmatch , below is the code for the same wich i added for both dimension Background color expression, You can use # color also example: #ccc etc...
 
pick(WildMatch(Dim1,'A','B','C','D'),'red','blue','green','#ccc')

ajaykakkar93_0-1677733924665.png

 

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

henrikalmen
Specialist
Specialist

It should workfor multiple conditions. But I see one issue in your expression: you should not have single qoutes around the rgb function. Do it like this: if(country='US', rgb(255,0,0), if(...

You could also use pick and match as Ajaykakkar93 suggested, but it doesn't have a fallback for "all other countries" like the if statement does.

Krish
Contributor III
Contributor III
Author

@henrikalmen  & @ajaykakkar93  My condition for dimension coloring is :

if(num(Score, '#.##')>=3.30,'#00FF00',

      if(num(Score, '#.##')>=2.30,'#FFFF00','#FF0000'

))

But this is not working. It always goes to else condition.

 

neerajthakur
Creator III
Creator III

if(num(Score, '#.##')>=3.30 and num(Score, '#.##')<2.30,'#00FF00',

      if(num(Score, '#.##')>=2.30 and num(Score, '#.##')<3.30,'#FFFF00','#FF0000'

))

 

Try this

Thanks & Regards,
Please Accepts as Solution if it solves your query.
Krish
Contributor III
Contributor III
Author

@neerajthakur I tried it, but it just doesn't work. I tried different combination of numbers like :

if(num(Risk_Score, '#.##')=3.30 ,'#00FF00',

if(num(Risk_Score, '#.##')=1.70 ,'#FFFF00'

))

henrikalmen
Specialist
Specialist

Try this:

if(num(num#(Risk_Score), '#.##')=3.30 ,'#00FF00',
if(num(num#(Risk_Score), '#.##')=1.70 ,'#FFFF00'
))

neerajthakur
Creator III
Creator III

Hi try this and let me know the output where value is 3.30

if(Risk_Score=3.30,red(),blue())

Thanks & Regards,
Please Accepts as Solution if it solves your query.
Krish
Contributor III
Contributor III
Author

@neerajthakur Its not working either. I tried 

1) =if([Workload.Risk_Score]=2.40,red,blue)

          This says "Error in expression".


2) =if([Workload.Risk_Score]=2.40,'#00FF00','#FFFF00')

          It always goes to Else part.

neerajthakur
Creator III
Creator III

Try with value which you have like 3.30 and 1.70,1.20 and use this red(),blue(),

The field you are using for coloring is it dimension or measure, if measure what's the expression.

It might be you are using some calculation for measure value and using different logic in color expression.

I can't see the search icon and hoping it's measure only. Share your measure expression to help better.

Thanks & Regards,
Please Accepts as Solution if it solves your query.