Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
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!

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

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;

View solution in original post

3 Replies
swuehl
Champion III
Champion III

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
Specialist
Specialist

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
Author

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;