Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
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
Highlighted
Champion III
Champion III

Re: Multiple Sum if

Can you share some sample data with expected output please?

Highlighted
Creator III
Creator 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'))

Highlighted
Contributor
Contributor

Re: Multiple Sum if

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

Highlighted
Contributor
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
Champion III
Champion III

Re: Multiple Sum if

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

Highlighted
Specialist
Specialist

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.