Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Dafna2020
Contributor
Contributor

Pick function for a background color doesn't work

Hi,

I defined colors for a conditional background:

KPIsColors:
//1=Red,2=light red,3=yellow,4=light green,5=green
LOAD *,Dual(_PickColorExp,_PickColorCodeNum) as PickColorRGB INLINE [
_PickColorCodeNum , _PickColorExp
1 , 'RGB(234,102,83)'
2 , 'RGB(245,183,175)'
3,  'RGB(230,219,91)'
4,  'RGB(172,209,24)'
5,  'RGB(111,149,21)'
];
 

Each condition compares a metric to 5 limits:

=Pick(num(PickColorRGB),
     ($(eYoYGrowth%_PrevYear) <=vRed%)*-1,
     ($(eYoYGrowth%_PrevYear) <=vLightRed%)*-2,
     ($(eYoYGrowth%_PrevYear) <=vYellow%)*-3,
     ($(eYoYGrowth%_PrevYear) <=vLightGreen%)*-4,
     ($(eYoYGrowth%_PrevYear)>vLightGreen%)*-5)

But the Pick function does not work as expected..

There is no background color..

Any Idea why?

Thanks!

 



Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda

I think this is not the correct way to map the colors. You need to check first expression condition and then define the color there. May be you can try something like below

Pick(match(-1,
     ($(eYoYGrowth%_PrevYear) <=vRed%),
     ($(eYoYGrowth%_PrevYear) <=vLightRed%),
     ($(eYoYGrowth%_PrevYear) <=vYellow%),
     ($(eYoYGrowth%_PrevYear) <=vLightGreen%),
     ($(eYoYGrowth%_PrevYear)>vLightGreen%)),

RGB(234,102,83),
RGB(245,183,175),
RGB(230,219,91),
RGB(172,209,24),
RGB(111,149,21))

View solution in original post

6 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Try:

=Pick(match(_PickColorCodeNum,1,2,3,4,5)
     ($(eYoYGrowth%_PrevYear) <=vRed%)*-1,
     ($(eYoYGrowth%_PrevYear) <=vLightRed%)*-2,
     ($(eYoYGrowth%_PrevYear) <=vYellow%)*-3,
     ($(eYoYGrowth%_PrevYear) <=vLightGreen%)*-4,
     ($(eYoYGrowth%_PrevYear)>vLightGreen%)*-5)

Dafna2020
Contributor
Contributor
Author

Hi,

Thank you...

Tried.. but it doesn't work..

 

 

 

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

You have a sample app?

Dafna2020
Contributor
Contributor
Author

No...

Kushal_Chawda

I think this is not the correct way to map the colors. You need to check first expression condition and then define the color there. May be you can try something like below

Pick(match(-1,
     ($(eYoYGrowth%_PrevYear) <=vRed%),
     ($(eYoYGrowth%_PrevYear) <=vLightRed%),
     ($(eYoYGrowth%_PrevYear) <=vYellow%),
     ($(eYoYGrowth%_PrevYear) <=vLightGreen%),
     ($(eYoYGrowth%_PrevYear)>vLightGreen%)),

RGB(234,102,83),
RGB(245,183,175),
RGB(230,219,91),
RGB(172,209,24),
RGB(111,149,21))

Dafna2020
Contributor
Contributor
Author

It works!

I used variables for the colors...:

Pick(match(-1,
$(eYoYGrowth%_PrevYear) <=vRed%,
$(eYoYGrowth%_PrevYear) <=vLightRed%,
$(eYoYGrowth%_PrevYear) <=vYellow%,
$(eYoYGrowth%_PrevYear) <=vLightGreen%,
$(eYoYGrowth%_PrevYear)>vLightGreen%),
$(vRGBRed),$(vRGBLightRed),$(vRGBYellow),$(vRGBLightGreen),$(vRGBGreen))

 

Thanks!