Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
We’re experiencing technical issues with our vendor that are affecting license activations for Designer Desktop. We don’t yet have an estimated resolution time. We apologize for the inconvenience and will share updates as we have them.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Rearranging Rows based on a key value

tarnold
5 - Atom

I want to add a sequence number to each of these rows the first row always has a 0 for Prev Logical Device and the last row always has a 0 for Next Logical Device.  Pretty easy to add the sequence number for the first row. How do I go through a list adding an incremental sequence number for the correct row.  You will see that row 1 under the headings is the first row but the next sequence number would actually be row 5.  Since the device numbers are not sequential sorting doesn't help except to find the first row.  Any help would be appreciated.

4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

@tarnold 

Maybe something like this?

1230-tarnold.PNG

tarnold
5 - Atom

Thank you for the reply I re-read my post so sorry it didn't fully explain.  I would like a sequence number for each row.  I have updated the sample to include an after run example.

danilang
19 - Altair
19 - Altair

Hi @tarnold 

 

In order to accomplish this, you need to iterate through the list several times.  First to find the starting device, then to find the 2nd device, etc.  In a macro-free workflow you could accomplish this by joining the list to itself 7 times to find the sequence, but you'd have to manually modify the workflow if you have a sequence with 8 devices.      

 

Luckily, you can solve this using an iterative macro that steps through the list once for every record.  

 

macro.png

The macro itself is about as simple as an iterative macro can be.  The filter sends the Target device out the Data output.  The Append Fields tool takes the next ID from the selected record and add that to the remaining records as the new TargetDeviceID and sends the remaining to the IterativeOutput that feeds back into the IterativeInput.  Each iteration removes one row from the remaining rows and stops when there are no remaining records or 1000 iterations, which ever comes first

 

The main workflow just sets things up to pass to the macro and adds the sequence ID to records

 

main.png

The 2 browse tools give you the output sorted by sequence id or the original id

 

Dan

 

tarnold
5 - Atom

Thanks Dan that worked perfectly.  It also taught me more about iterative macros.  I appreciate the assist.

Labels
Top Solution Authors