Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
infock12
Creator III
Creator III

Multiple IF, PICK AND MATCH

Hello all,

I have a load script that I used to change the text in a field to a different text based on the Question number. This says that if the value of QuestionNumber 25 is 'Yes', change it to ;No' and vice versa.

IF(Match(QuestionNumber, 25), Pick(Match(CResponse,'Yes','No', CResponse),'No','Yes', CResponse) as Response;

How do I add another IF statement to say for QuestionNumber 26, if there is a 'No' response say 'Yes', but if there is a 'Yes' response, leave it as 'Yes'

I tried the below but it didn't work.

IF(Match(QuestionNumber, 25), Pick(Match(CResponse,'Yes','No', CResponse),'No','Yes', CResponse) AND IF(Match(QuestionNumber, 26), Pick(Match(CResponse,'No', CResponse), 'Yes', CResponse) as Response;

I tried connecting two IF statements with a comma instead of 'AND' but that did not work either.

Any help is appreciated!

1 Solution

Accepted Solutions
maxgro
MVP
MVP

IF(Match(QuestionNumber, 25), Pick(Match(CResponse,'Yes','No', CResponse),'No','Yes', CResponse),

IF(Match(QuestionNumber, 26), Pick(Match(CResponse,'Yes','No', CResponse),'Yes','Yes', CResponse),

'no 25 or 26'

))

as Response

View solution in original post

10 Replies
maxgro
MVP
MVP

IF(Match(QuestionNumber, 25), Pick(Match(CResponse,'Yes','No', CResponse),'No','Yes', CResponse),

IF(Match(QuestionNumber, 26), Pick(Match(CResponse,'Yes','No', CResponse),'Yes','Yes', CResponse),

'no 25 or 26'

))

as Response

Qrishna
Master
Master

Not sure, if you need this.

sunny_talwar

This may be:

IF(Match(QuestionNumber, 25), Pick(Match(CResponse,'Yes', 'No', CResponse),'No','Yes', CResponse), IF(Match(QuestionNumber, 26), Pick(Match(CResponse,'No', CResponse), 'Yes', CResponse), CResponse)) as Response;

infock12
Creator III
Creator III
Author

Thanks Massimo! However, it gives the value as  'no 25 or 26' for the whole column. I think it is because we are saying 'no 25 or 26' before the double brackets in the end.

I tried:

IF(Match(QuestionNumber, 25), Pick(Match(CResponse,'Yes','No', CResponse),'No','Yes', CResponse),

IF(Match(QuestionNumber, 26), Pick(Match(CResponse,'Yes','No', CResponse),'Yes','Yes', CResponse),

CResponse)) as Response;

and this worked!!

Thanks for your help.

sunny_talwar

Awesome

I suggest closing the thread by marking a correct answer.

Best,

Sunny

maxgro
MVP
MVP

I don't know what did you want for

not 25 and not 26

so I typed a constant 'no 25 or 26'  to be replaced

qlikviewwizard
Master II
Master II

Hi Infock12

Please close the thread by selecting Correct Answer and Helpful. Thank you.

infock12
Creator III
Creator III
Author

I Understan. Thanks M!‌

infock12
Creator III
Creator III
Author

T‌hanks Sunny, Krishna and Qlikviewwizard!