A client asked us for a method of importing a list of URNS and Dates, into an existing FastStats system, and then to suggest a method to compare the imported date to other dates for the same URN in order to then provide the previous date attached to that URN.
To do this we carried out the process below (in this example within the Apteco Training system):
We created a list of URNs and Dates in the format the client was using:
Person URN, Booking Date
96,09/02/2023
135,19/02/2023
134,07/02/2023
147,17/05/2022
334,13/04/2023
437,14/06/2023
622,20/06/2023
723,10/06/2023
725,18/08/2023
727,06/04/2022
We used the Import Data Wizard to import the dates onto the Person table. Within the wizard changing the format of the data to match the rows in the system:
The variable was named as 'Imported Date'
Click the Expression button
Set the Resolve Table to be Bookings
Create an Expression like this:
This just flags a 1 if the Booking Date on that Booking record is older than the date imported at the Person table level. We used the Month() function to check that the Imported Date is not Unclassified because we only want to flag records that are present in the imported file. Any blank dates would have a month of 0.
Drag this Expression onto a new Selection
Enter a value of 1 as the selection criteria.
This selection is then selecting all the transactional (Booking) records which are more recent than the Imported Date.
We named this selection 'Older Transaction Flag' :
Now, click the Expression button to create a new Expression
Click the Aggregation button
Specify the Type as Recency
Set the Order records by to be Booking Date
Leave the From as Latest to Earliest as we want the most recent one
Set the Pick the option to be Booking Date
Drag and drop the filtered selection onto the Using these transactions drop area:
This Expression then looks like this:
This produces the required Last Date before the Imported Date.
Putting this on a Data Grid to confirm:
The New Expression 4 column shows the date returned by the on-the-fly aggregation. It should be the first populated date that occurs before the date we imported.