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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

where clause inside if statement

I have a small piece of code which basically checks if the question is 2 or 3 and

If the question is 3, it saves the corresponding answer as Final answer.

What I need is if the question is 2, it shows test for now but  I would still like to save the Final answer as whatever was answer for question 3.

Is there a way I can achieve this? Any help will be appreciated

LOAD distinct

     DataPoint,

     if (Question=3,Answer,'test' ) as [Final Answer]

FROM

$(vQVDLocation)DataPointAnswerChoice.qvd

(qvd) where match(Question,2,3);

The pseudo code is something along below lines

if( question =3, answer, ( answer where question would have been 3) )

12 Replies
anbu1984
Master III
Master III

Tbl:

LOAD distinct

     DataPoint,

     if (Question=3,Answer,'test' ) as Answer3,

     Question

FROM

$(vQVDLocation)DataPointAnswerChoice.qvd

(qvd) where match(Question,2,3);

Join(Tbl)

LOAD

     DataPoint,

     2 As Question,

     Answer As Answer2

FROM

$(vQVDLocation)DataPointAnswerChoice.qvd

(qvd) where Question=3;

Final:

Load *, if (Question=3,Answer3,Answer2 ) as [Final Answer] Resident Tbl;

Drop Table Tbl;

Not applicable
Author

Thank you so much anbu cheliyan. That fix worked like a charm.

Not applicable
Author

Thanks for trying to help Robert, Anbu Cheliyan helped me solve it.