Alert: There is a planned Community maintenance outage October 16th from approximately 10 - 11 PM PST. During this time the Alteryx Community will be inaccessible. Thank you for your understanding!

Alteryx Designer Desktop Discussions

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

How to get the two most recent dates of every ID

Hi!

 I'm struggling to analyze the following sample table in the following way:

Observation: date format "DD/MM/YYYY"

Step 1 - Input

IDTraining dateExpiration date
11/1/20211/1/2022
11/1/20221/2/2023
11/1/20231/1/2024
21/2/20221/2/2023
21/3/20231/3/2024
32/3/20232/3/2024

 

With this table I need to rank and filter the two most recent Training dates of every ID, if an ID has less than two register, there's no harm:
Step 2

IDTraining dateExpiration dateRank training date
11/1/20221/2/20232
11/1/20231/1/20241
21/2/20221/2/20232
21/3/20231/3/20241
32/3/20232/3/20241

 

And, after that I want to compare the expiration training date ranked as second with the most recent training date and see if every ID joined a new training seven days before the expiration date, like this:
Step 3 - Output

IDTraining dateExpiration dateRank training dateRenewed before expiration?
11/1/20221/2/202320
11/1/20231/1/202411
21/2/20221/2/202320
21/3/20231/3/202410
32/3/20232/3/202410


Thank you in advance!

3 RÉPONSES 3
cjaneczko
Pulsar

For Step 2 you can sort your data first by ID Ascending, then by Training Date Descending. Then add a multi row formula tool after it. In the tool use the below formula. Then add a filter tool after the multirow tool that filters anything less than or equal to 2. That should give you the data set for Step 2. As for step 3 I don't quite follow the logic. Can you provide more detail? It sounds like a simple IF formula will solve this.

 

if isnull([Row-1:Rank]) then 1 elseif [Row-1:ID]=[ID] then [Row-1:Rank]+1 else 1 endif

 

Thank you for the fast answer!

 I'll try to explain it better.
 
 In the step 3 I need to I to compare the expiration date ranked as 2 for every ID with the training date ranked as 1 for the same ID, so for exemple:
ID: 4
Most recent training date: 1/3/2023
Second most recent expiration date (the previous training date expiration): 18/4/2023
Did the ID renewed the training 7 days or more before the expiration date? Yes (1) or No (0). In this case, it should be 'yes' because we have more than 7 days of difference between the most recent training date and the previous training expiration date.

Thank you again!

ed_hayter
Quasar

@pedrobeltrameseis this what your looking for?

 

image.png

 

I parsed the dates and then did some multi-row calcs to rank and then look back and see if the ID was renewed in time.

 

Note that I parsed the dates as day month but if its month day you'd have to adjust the multi-field formula

Étiquettes