Quantcast
Channel: Data Preparation & Blending discussions
Viewing all articles
Browse latest Browse all 4999

grouping rows for consecutive dates (with two criterias)

$
0
0

Hello All,
I'm new in Alteryx and until now most of my work I made using Excel and VBA - so please excuse me if my case is insolvable in ALTX - I simply do not know limitation of the program.
Right now I'm trying to learn this new tool and move some (preferably most) of the processes related to data preparation to ALTX.

In this case I need to merge/group rows for consecutive Trips into one, keeping information about earliest start date and latest end date for the destination.
Rows are to be grouped ONLY for same TRIP ID and Country.

 

Continuous trip means both:

1) start date 1 : 1/1/2017 end date 1: 1/2/2017; start date 2: 1/2/2017 end date 2: 1/4/2017

2) start date 1: 1/1/2017 end date 1: 1/2/2017; start date 2: 1/3/2017

 

So for Trip ID 321, I need to check if "Country" is repeating and if the trip is continuous and merge it into 1 row, for 123 there is no continuity:

 

TRIP IDCountrystart dateend datenumber of days in travel   TRIP IDCountrystart dateend datenumber of days in travel
123Poland1/1/20171/3/2017    123Poland1/1/20171/3/2017 
123Germany1/3/20171/5/2017    123Germany1/3/20171/5/2017 
123Poland1/5/20171/7/2017 
 
   
 
123Poland1/5/20171/7/2017 
321Germany1/2/20171/4/2017 321Germany1/2/20171/6/2017 
321Germany1/4/20171/6/2017 111Poland1/10/20171/12/2017 
111Poland1/10/20171/12/2017 222Poland1/14/20171/27/2017 
222Poland1/14/20171/20/2017         
222Poland1/21/20171/23/2017         
222Poland1/24/20171/27/2017         

 

 

I'm attaching file with the example (presented in table above), and sample data.

 

I've solved it using VBA loops and tabular formulas but I have not idea how to solve it in ALTX.

 

Thank you for help

 

Have a great weekend.


Viewing all articles
Browse latest Browse all 4999

Trending Articles