Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Tile Tool? How can I return the first date/time stamp following key code records?

ddiesel
13 - Pulsar
13 - Pulsar

I am stuck on one piece of a workflow and I'm hoping someone in the community can help me. In my data set, there are letter codes (example: AB, CD, EF, GH...) with date/time stamps that are related to a Ref# (example: 12345678). Also in the data set are "key" codes indicated with "XX". For each letter code (AB, CD, EF, GH...) I need to determine the first date/time stamp of the XX code that occurred after the letter code.

 

In other words, the letter codes (example: AB, CD, EF, GH...) signify events. The XX code indicates that the event was acknowledged. I need to determine the first acknowledgement date/time that occurred after the event. If not acknowledged yet, I need to indicate null or "NO XX". 

 

Difficult to explain so I have prepared some examples:

 

Scenario 1

Ref#DateTimeCode1ST XX DATE1ST XX TIME
123456777/10/201718:40ABNO XXNO XX

(No XX found for this Ref# in the data. "No XX" returned in last two columns)

 

Scenario 2

Ref#DateTimeCode1ST XX DATE1ST XX TIME
123456787/11/201718:40AB7/11/201718:41
123456787/11/201718:41XX  

(Most common scenario. Event AB occurred at 18:40 and was acknowledged by XX event at 18:41. The XX date/time is returned in last two columns.)

 

Scenario 3

Ref#DateTimeCode1ST XX DATE1ST XX TIME
123456797/12/201719:40CD7/12/201719:41
123456797/12/201719:41XX  
123456797/12/201719:42XX  
123456797/12/201719:43XX  

(Event CD occurred and was acknowledged 3 times. Only the first XX date/time is returned. The others are irrelevant.)

 

Scenario 4

Ref#DateTimeCode1ST XX DATE1ST XX TIME
123456837/13/20177:08EF7/13/20177:09
123456837/13/20177:09XX  
123456837/13/20178:10EF7/13/20178:11
123456837/13/20178:11XX 

 

(Two events occurred on this Ref#. The second EF is considered a new event, therefore, the first XX date/time after the 2nd event is returned. This may happen many times with an event followed by an acknowledgement or multiple acknowledgements. The letter codes may change each time and are not always the same. Example: each event could be any combination of letter codes except XX.)

 

Scenario 5

Ref#DateTimeCode1ST XX DATE1ST XX TIME
123456847/13/20172:42AB7/13/20172:43
123456847/13/20172:43XX  
123456847/13/20173:22CD7/13/20173:23
123456847/13/20173:23XX  
123456847/13/20173:24XX  
123456847/13/20174:55CDNO XXNO XX

(This combines scenario 1 and scenario 5. The last event CD at 4:55 has no XX event that occurred after the 2nd CD was entered and therefore "NO XX" is returned.)

 

Scenario 6

Ref#DateTimeCode1ST XX DATE1ST XX TIME
123456857/16/20178:12AB7/16/20178:13
123456857/16/20178:13XX  
123456857/16/20173:22AB7/16/20173:23
123456857/16/20173:23XX  
123456857/16/20173:24XX  
123456857/17/20174:55CD7/17/20174:57
123456857/17/20174:56EF7/17/20174:57
123456857/17/20174:57   

(Two additional events occurred on 7/17/17. The XX at 4:57 is considered acknowledgement for both events CD and EF. XX at 4:57 is still the first XX that occurred after both the CD and EF events.)

 

Attachment:

Scenarios: Lists the scenarios posted above

Data In: Sample of data input based on scenarios provided

Data Out: Sample of desired output based on scenarios provided

More Sample Data: Additional sample data (400 records)

 

My coworker suggested the Tile tool. I would be very interested to see if that tool could be applied to these scenarios.

2 REPLIES 2
Joe_Mako
12 - Quasar

How about something like the attached?

 

1stxx.png

 

- Record ID to keep track of the original sort order, and create a unique identifier
- Sort on Ref# Ascending, and then Date and Time Descending
- Multi-Row Formula tool to calculate "1st XX Record ID" with the logic:

IF [Code]="XX" THEN Null()
ELSEIF [Row-1:Code]="XX" THEN [Row-1:RecordID] 
ELSE [Row-1:1st XX Record ID] ENDIF

- Join Multiple to bring in the 1st XX Date and Time
- Filter to remove the the unmatched records
- Sort to return to original record sequence

ddiesel
13 - Pulsar
13 - Pulsar

BRILLIANT! Problem Solved. Thank you very much!

Labels