Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
chinnu123
Creator
Creator

how to write case statement with COALESCE

Hi Team,

Can any one tell me how to write case statement with COALESCE in qlikview. please convert below below sql code in to qlik

CASE

            WHEN (COALESCE(INCIDENT.Incident_ID,0) > 0)

            THEN  'TRUE'

            ELSE 'FALSE'

      END AS FLAG,

Thanks,

Chinnu.

5 Replies
prma7799
Master III
Master III

   =if(INCIDENT.Incident_ID > 0, 'Yes', 'No' )



For checking null there is the isnull() function

     where isnull(Incident_ID=0)

devarasu07
Master II
Master II

Hi,

u can write like this,

if( INCIDENT.Incident_ID >0 , 'TRUE','FALSE') AS FLAG,

  COALESCE  mean not null values?  if so then try like below,

if( INCIDENT.Incident_ID >0 and len(INCIDENT.Incident_ID)>0 , 'TRUE','FALSE') AS FLAG,


and also u can use below way for not null

Not IsNull(INCIDENT.Incident_ID)


Regards,

Deva

chinnu123
Creator
Creator
Author

Hi P M,

Thanks for your quick reply if I am using the above syntax I am getting only true values. I am not getting false values

Thanks,

Chinnu.

jonathandienst
Partner - Champion III
Partner - Champion III

For numerics, the equivalent function to SQL COALESCE in QV is Alt():

If(Alt(INCIDENT.Incident_ID, 0) > 0, 'TRUE', 'FALSE' )  


Note that the QV is not totally the same as COALESCE because COALESCE works with non-numeric types as well, while the QV Alt() function only handles numerics.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
prma7799
Master III
Master III

as @jonatham suggest

Please try this

If(Alt(INCIDENT.Incident_ID, 0) > 0, 'TRUE', 'FALSE' )