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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Change colour textbox if and

Hi everyone,

I have been trying to change the colour of a textbox according to a certain condition. Unfortunately it does not seem to work when I have "AND" conditions under an IF statement. The expression that I cannot make it work is the following:

=IF(Brand='X AND Brand='Z' AND  Brand='Y', RGB(0,240,0), RGB(0,39,130))

The problem seems to be in the "AND" since this expression works perfectly well when I only have one condition!

Anyway I need to highlight that text box anytime Brands X, Z and Y are selected simultaneously! Any ideas?

1 Solution

Accepted Solutions
sunny_talwar

May be try this:

If(

SubStringCount('|' & GetFieldSelections(Brand, '|,|') & '|', '|X|') = 1 and

SubStringCount('|' & GetFieldSelections(Brand, '|,|') & '|', '|Y|') = 1 and

SubStringCount('|' & GetFieldSelections(Brand, '|,|') & '|', '|Z|') = 1, RGB(0,240,0), RGB(0,39,130))

View solution in original post

7 Replies
sunny_talwar

May be try this:

If(

SubStringCount('|' & GetFieldSelections(Brand, '|,|') & '|', '|X|') = 1 and

SubStringCount('|' & GetFieldSelections(Brand, '|,|') & '|', '|Y|') = 1 and

SubStringCount('|' & GetFieldSelections(Brand, '|,|') & '|', '|Z|') = 1, RGB(0,240,0), RGB(0,39,130))

Anonymous
Not applicable
Author

You are missing a single quote on X.

marcus_sommer

I think you will need an OR instead of an AND - but try it in this way:

=IF(match(Brand, 'X', 'Z', 'Y'), RGB(0,240,0), RGB(0,39,130))

- Marcus

maxgro
MVP
MVP

try with

=if(Concat(DISTINCT Brand, '', Brand) = 'XYZ', RGB..., RGB....)

Anonymous
Not applicable
Author

Try this

= if(GetFieldSelections(Brand) = 'X, Y, Z', RGB(0,240,0), RGB(0,39,130))

Anonymous
Not applicable
Author

Thanks a lot to all.

Anil_Babu_Samineni

I like this hard code.  Let's assume if we do have A-Z then do we require to loop 26 times. Or any other solution to achieve. I appreciate your inputs

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful