Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
proctors
Creator
Creator

Calculating Date Difference Between Rows

We are trying to work out calculations to tell us the difference between the first time a patient was called for a referral and the first visit they came to the clinic (=Time to Be Seen).

My data looks like the following:

  

IDEncounter TypeReason for VisitDate
9999OFFICE VISITVisit2/20/2017
9999OFFICE VISITVisit12/16/2016
9999OFFICE VISITVisit5/11/2017
9999TELEPHONECall11/8/2016
9999TELEPHONECall10/31/2016

The end Result would be

IDDate of 1st CallDate of 1st VisitDifference Between Dates
5 Replies
Anil_Babu_Samineni

Can u explain the result set?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ahaahaaha
Partner - Master
Partner - Master

Hi,

Dimension: ID


Expression Date of 1st Call:

Min ({<[Encounter Type]={'TELEPHONE'}>}Date)


Date of 1st Visit:

Min ({<[Encounter Type]={'OFFICE VISIT'}>}Date)


Difference Between Dates:

Min ({<[Encounter Type]={'OFFICE VISIT'}>}Date)-Min ({<[Encounter Type]={'TELEPHONE'}>}Date)


Result (I added another ID)

1.jpg

Look attached file.

Ragards,

Andrey

proctors
Creator
Creator
Author

This works pretty well!  However, when I looked at other IDs, we saw that some had the following. In this scenario, the min Office visit comes before the telephone call. We want to look forward, someone calls, then has a visit, thus ignoring visits before.

IDEncounter TypeReason for VisitDate
9999OFFICE VISITVisit2/20/2017
9999OFFICE VISITVisit12/16/2016
9999OFFICE VISITVisit5/11/2017
9999TELEPHONECall11/8/2016
9999TELEPHONECall10/31/2016
9999OFFICE VISITVisit4/2/2016

How can I adjust the expression so that it only looks at the first Office Visit after the 1st Telephone call?

Expected Result

IDDate of 1st CallDate of 1st Visit (after 1st call)Difference Between Dates
999910/31/201612/16/2016
vvvvvvizard
Partner - Specialist
Partner - Specialist

Try aggr ahaahaaha reply

Min(Agrr( Min ({<[Encounter Type]={'TELEPHONE'}>}Date), ID))

proctors
Creator
Creator
Author

I'm sorry, what expression is this replacing above? Seems to be returning the ID and not the corrected date difference.