Free Trial

Alteryx Designer Desktop Discussions

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

Matching to the largest number smaller than X

danago
5 - Atom

Hi. I have a column of consecutive dates:

 

Data set 1

 

Date
Jan 1
Jan 2
Jan 3
...
Dec 31

 

I have another data set where each row is an "activity", and the columns are "activity description" and "date"

 

Data set 2

Desc.Date
Activity 1Jan 1
Activity 2Jan 3
Activity 3Apr 23
Activity 4Oct 14

 

What I want to do is create a new dataset, which is basically the same as "Data set 1" (i.e. the first column will be every date from Jan 1 to Dec 31), but the second column will be whatever the last activity to occur was (i.e. for a given row/date, what is the largest date in "Data set 2" that is less than the date in the new row). So, as an example, it would look something like this:

 

Data set 3

DateLast activity
Jan 1Activity 1
Jan 2Activity 1
Jan 3Activity 2
Jan 4Activity 2
Jan 5Activity 2
...Activity 2
Apr 21Activity 2
Apr 22Activity 2
Apr 23Activity 3
Apr 24Activity 3

 

Is there a simple way to do this type of matching in Alteryx? 

 

Thanks in advance,
Dan

3 REPLIES 3
Bob_Blackey
11 - Bolide

Hi Dan,

 

I've attached a workflow which does it.

 

You join the two sources together (by date) and then Union two of the outputs to get the full year of dates again.

 

Then with the Multi-Row Formula Tool you look at description field and if it is blank use the value from the previous row.

 

 

Cheers,

Bob

 

Match.png

pcatterson
11 - Bolide

I approached it similarly, but instead of using a join, I generated the dates.  See attached.

danago
5 - Atom

Thanks for these suggestion Bob and pcatterson - much appreciated! 

Labels
Top Solution Authors