Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

jweber917
New Contributor

Multiple Sum if

if(sum(if(DHVNHFProtocolCareStepPerfMeasures.DocDayAfterDischarge <= 2 and DHVNHFProtocolCareStepPerfMeasures.ApptConf = 'Y',1,0))>=1,'Y', sum(if(DHVNHFProtocolCareStepPerfMeasures.DocDayAfterDischarge > 2 and DHVNHFProtocolCareStepPerfMeasures.ApptConf = 'Y',1,0))>=1,'L',’N’) 

it doesn't like my above set analysis expression for my qlik chart.. why?

Essentially I want it to mark all my appointments that are less or equal to 2 as a Y (Yes), if they were conducted BUT over 2 days then a L (or late) and if they were not done at all as N (or NO).. can I do this the way I'm writing it?

6 Replies
vishsaggi
Esteemed Contributor III

Re: Multiple Sum if

Can you share some sample data with expected output please?

sibin_jacob
Contributor III

Re: Multiple Sum if

Try this one


if(DHVNHFProtocolCareStepPerfMeasures.DocDayAfterDischarge <= 2 and DHVNHFProtocolCareStepPerfMeasures.ApptConf = 'Y' ,'Y',

if(DHVNHFProtocolCareStepPerfMeasures.DocDayAfterDischarge > 2 and DHVNHFProtocolCareStepPerfMeasures.ApptConf = 'Y' ,'L','N'))

jweber917
New Contributor

Re: Multiple Sum if

this is giving me a No (N) for ones that should be Yes (Y)

jweber917
New Contributor

Re: Multiple Sum if

Right now I'm doing it in my SQL code instead and writing it like this... rather than within Qlik.

case when sum( case when  ApptConf = 'Y' and DocDayAfterDischarge <= 2 then 1 else 0 end) >= 1 then 'Y'

when sum( case when ApptConf = 'Y' and DocDayAfterDischarge > 2 then 1 else 0 end) >= 1 then 'L'

else 'N' end as ApptConfFinal

Highlighted
vishsaggi
Esteemed Contributor III

Re: Multiple Sum if

OK so does this work as expected when you run from SQL?

vamsee
Valued Contributor

Re: Multiple Sum if

Maybe try this

IF(

DHVNHFProtocolCareStepPerfMeasures.ApptConf = 'Y', /** Check for ApptConf **/

IF(

DHVNHFProtocolCareStepPerfMeasures.DocDayAfterDischarge <= 2, /** Appointments <2 days **/

'Y',

IF(

DHVNHFProtocolCareStepPerfMeasures.DocDayAfterDischarge > 2, /** Appointments >2 days **/

'L',

'N'

)

)

)

Thanks.