Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Adding a flag in a script

Hi,

I have a Patients table and Clinique Visits table.

Not all patients have visits records.

I’d like to add a flag to the Patients table

That represents when no visits exists for the relevant patients.

The following left join doesn’t work.

Left Join (Patients)

LOAD

PatientID,
'No'
as WithClnVisits

Resident [Clinique Visits]
Where not Exists (PatientID);

Any idea why?

Thanks!

1 Solution

Accepted Solutions
MVP
MVP

Re: Adding a flag in a script

Try like this:

Visits:

LOAD
PatientID as PatientVisitID
Resident [Clinique Visits];

Patients:

LOAD

     PatientID,

     if(exists(PatientVisitID, PatientID),'Yes','No') as WithClnVisits,

     ...

FROM PatientsTable.;

Drop table Visits;

3 Replies
MVP
MVP

Re: Adding a flag in a script

Try like this:

Visits:

LOAD
PatientID as PatientVisitID
Resident [Clinique Visits];

Patients:

LOAD

     PatientID,

     if(exists(PatientVisitID, PatientID),'Yes','No') as WithClnVisits,

     ...

FROM PatientsTable.;

Drop table Visits;

srchilukoori
Valued Contributor

Re: Adding a flag in a script

You need to do an inner Join with the clinic visits first, and add a flag 'Yes'. Then concatenate the Resident PatientID table with Where not exists condition.

Not applicable

Re: Adding a flag in a script

Hi,

Thanks a lot!

Never saw this syntax before :-)

I managed to achieve the desied result with using the condition in a left join:

Left Join (Patients)

LOAD

     PatientID,

     if(exists(QlnPatientID, PatientID),'Yes','No') as WithClnVisits

    

Resident Patients;

Community Browser