Start Free Trial

Alteryx Designer Desktop Discussions

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

Nearest Date Filtering query

Gaurab_Bhattacharya
7 - Meteor

Hello,

 

I need a help. For example I have the attached Data set :

 

IDDate_1Date_2Days Difference
1111110/11/201910/10/2019-1
1111110/11/201910/13/20192
1111110/11/201910/16/20195
444447/1/20196/26/2019-5
444447/1/20197/3/20192
444447/1/20196/29/2019-2
5555512/16/201912/13/2019-3
555556/24/20197/1/20197
5555512/27/201912/30/20193
222227/10/20197/8/2019-2
2222212/27/201912/30/20193
2222212/27/201912/28/20191

 

- I want to filter this data set based on the nearest 'Date_2' compared to 'Date_1'.

 

- For example, for ID 11111, 'Date_2' (10/10/2019) is the nearest to the 'Date_1' (10/11/2019). In another word I need to take the 'Days Difference' which is nearest to zero (0), it may negative difference or positive difference.

 

- Now there is another condition. For example for ID 44444, the closest 'Date_2' is either 7/3/2019 or 6/29/2019 compared to 'Date_1' (7/1/2019). The 'Days Difference' is same for both the days. In this case I need to take the positive nearest difference date that is 7/3/2019.

 

The final output will be like this :

 

IDDate_1Date_2Days Difference
1111110/11/201910/10/2019-1
444447/1/20197/3/20192
5555512/27/201912/30/20193
2222212/27/201912/28/20191

 

It will be a great help if anyone can resolve this query.

 

Regards,

 

Gaurab

2 REPLIES 2
DavidP
17 - Castor
17 - Castor

Hi @Gaurab_Bhattacharya 

 

This is how I would do it, defining the absolute difference and then using a sort and sample tool.

 

DavidP_0-1599518530616.png

 

Gaurab_Bhattacharya
7 - Meteor

Hi David,

 

Thanks a lot.

 

Regards,

 

Gaurab

Labels
Top Solution Authors