community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Sorting based on different column in previous row

Alteryx Certified Partner

Hi All,

 

Need some help sorting data based on a different column and previous row.

 

Attached is a sample of what the data looks like and what I want to achieve as a result.

 

Thanks in Advance

Alteryx Certified Partner
Alteryx Certified Partner

@ReinierK,

 

I'd create a metadata input that includes a SORT_ORDER field for column A.  Home = 0, First = 1 etcetera.  Using a Find Replace tool, I'd add that field to the initial table and sort on the new SORT_ORDER field.  Once the field is used, you can de-Select it.

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Meteoroid

Any luck with this? I also have data that has not been sorted, my project requires data in a similar format:

 

Raw Data

Starting StationStopping Station
SandringhamHampton
BrightonElsternwick
RipponleaGardenvale
HamptonBrighton
ElsternwickRipponlea

 

 

Sorted Data - Objective

Starting StationStopping StationJourney
SandringhamHampton1
HamptonBrighton2
BrightonElsternwick3
ElsternwickRipponlea4
RipponleaGardenvale5

 

Can anyone help us with an example workflow?

Alteryx Certified Partner

Hi @Johnehbon,

 

The solution to this is an iterative macro.

 

Please see attached.

 

Reinier.

Meteoroid

Thank you very much!

Highlighted
Meteoroid

Hey ReinierK, 

 

Just wanted to confirm with you that the following is the logic behind the workflow:

 

- You have programmed the workflow such that the input list is effectively joining for the second column's record in the first column using the sample tool to skip the first row and attaching it back into the list to find itself... 

- The iterative macro is required because you are effectively using the 2nd columns first row to do a vlookup (in excel land) of itself in the first column which will then loop the "remaining" records to find itself again...

 

Just wondering how I can explain the logic behind this to others...keen to hear your thoughts & explanation.

Labels