Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gopikrishnach
Creator
Creator

Case statement Replacement

Hi, In my application so many CASE statements have been used to extract the data from database at script level. But today I got requirement that need to replace CASE statements with qlik functions. But I am not able to find that. Could you please some one help me?

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

case when (((Eleven_Tables44.COMP_NUMBER = 1) and (Eleven_Tables44.RESULT_TYPE = 'T3')) or ((Eleven_Tables44.UNIT_NUMBER = 1) and (Eleven_Tables44.RESULT_TYPE = 'T4'))) then Eleven_Tables44.PRIMARY_LIMITS else '' end  as  PRIMARY_LIMITS

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I tried with If Condition, but the data is not coming correctly.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

IF(((COMP_NUMBER=1 AND RESULT_TYPE='T3') OR (UNIT_NUMBER=1 AND RESULT_TYPE='T4')),PRIMARY_LIMITS,'') AS PRIMARY_LIMITS_1

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Thank you.

5 Replies
dapostolopoylos
Creator III
Creator III

The transalation of SQL to Qlik script you did is correct, i wouldn't do it in a different way...

Is it possible that your data when they are downloaded to Qlik are somehow affected in a way?

Father/Husband/BI Developer
Vasiliy_Beshentsev
Creator III
Creator III

try this

if((Eleven_Tables44.COMP_NUMBER = 1 and Eleven_Tables44.RESULT_TYPE = 'T3')

or (Eleven_Tables44.UNIT_NUMBER = 1 and Eleven_Tables44.RESULT_TYPE = 'T4'), Eleven_Tables44.PRIMARY_LIMITS, '')

vikasmahajan

you can use pick match like following syntax

pick(match("COMPANY_NAME",'A','B','C',"COMPANY_NAME"),'COMP A','COMP B','COMP C') as COMP,

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
gopikrishnach
Creator
Creator
Author

Hi Vasiliy, I tried your code, but it is not working. Still the data is not matching. Thank you.

gopikrishnach
Creator
Creator
Author

Hi Vikas, Can you please elaborate, How will use pick match here.