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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
g23
Contributor III
Contributor III

Multiple if statement color expression in a pivot table

Hi all,

I am new user of Qlik Sense and I'm trying to write a multiple if color expression for a measure calculated using set analysis but I can't write the expression does not seems to work if a try to insert more than one if statement at the time.

Measure variable: Count({$<[Tipo Conversione]={D}>}[ID Polizza]) / Count(distinct{$<flg_first_policy>}[ID Lead])

Color expression (wrong): if(Count({$<[Tipo Conversione]={D}>}[ID Polizza]) / Count(distinct{$<flg_first_policy>}[ID Lead])<0.04, rgb(51,51,255)),

if(Count({$<[Tipo Conversione]={D}>}[ID Polizza]) / Count(distinct{$<flg_first_policy>}[ID Lead])>=0.04,rgb(0,51,102),rgb(51,51,102))

Can someone give me any advice on how to do this??

Thanks

Labels (1)
3 Replies
Vicky_Z
Support
Support

@g23 

Firstly, is your variable getting value?

If I simplify your color expression, I get: 

if(measure<0.04, rgb(51,51,255)),

if(measure>=0.04,rgb(0,51,102),rgb(51,51,102))

 

I am a little confused. Could you please clarify how you would like to define the colour? 

 

 

 

 

felcar2013
Partner - Creator III
Partner - Creator III

hi

in the first part of your measure write {D} like {'D'}, because it is text!

in the second part of your expression  <flg_first_policy> equals what? otherwise you need TOTAL before

if you want to fix it then write <flg_first_policy=>

 

dplr-rn
Partner - Master III
Partner - Master III

couple of things

your syntax is wrong  closing of brackets is not right

if(Count({$<[Tipo Conversione]={D}>}[ID Polizza]) / Count(distinct{$<flg_first_policy>}[ID Lead])<0.04, rgb(51,51,255), //deleted 1 bracket

if(Count({$<[Tipo Conversione]={D}>}[ID Polizza]) / Count(distinct{$<flg_first_policy>}[ID Lead])>=0.04,rgb(0,51,102),rgb(51,51,102)) ) // added one bracket

Second

the else condition in your second if will never be satisfied. first if is measure<0.04 so when you do second if measure>=0.04 it will always be true. so not sure if you defined these correctly