Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
proctors
Creator
Creator

Help with Load Script for Min Date and Field

I have the following data for one (fake) patient in a table box.

I need the last column to give me the Department that matches the Office Visit Min Date. The Office Visit Min date is calculated as the min Office Visit after the Insurance Date Min. I've tried lots of things and just can't get it to work in my Load Script.

LOAD MRN,

date(min(if([Office Visit Date]>[Primary_Insurance_Date_Min],[Office Visit Date]))) as [Office Visit Date Min]

Resident Data

Group by MRN;

      

MRNPrimary_Insurance_Date_MinOffice Visit Date MinOffice Visit DatesOffice Visit DepartmentOffice Visit Date Min Department
9997/21/20168/29/20162/4/2016MKT 3440 BEHAVIORAL HL
9997/21/20168/29/20168/29/2016MKT 3440 BH AUTISM
9997/21/20168/29/201611/16/2016MKT 3440 BEHAVIORAL HL
9997/21/20168/29/20161/11/2017MKT 3440 BEHAVIORAL HL
9997/21/20168/29/20163/8/2017MKT 3440 BEHAVIORAL HL
9997/21/20168/29/20165/3/2017MKT 3440 BEHAVIORAL HL
9997/21/20168/29/20167/13/2017MKT 3440 BEHAVIORAL HL

I hope the result could be the following once I remove the Office Visits Column.

    

MRNPrimary_Insurance_Date_MinOffice Visit Date MinOffice Visit Date Min Department
9997/21/20168/29/2016MKT 3440 BH AUTISM
1 Reply
antoniotiman
Master III
Master III

Hi Stephon,

try this Script

Table:
LOAD MRN,
Primary_Insurance_Date_Min,
[Office Visit Dates],
[Office Visit Department]
FROM
"https://community.qlik.com/message/1311047"
(html, codepage is 1252, embedded labels, table is @1);
Inner Join
LOAD MRN,Date(Min([Office Visit Dates])) as [Office Visit Dates]
Resident Table
Where [Office Visit Dates] >= Primary_Insurance_Date_Min

Group By MRN;

Regards,

Antonio