Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Copy Row 'x' (defined in another column) times

Dezzie
5 - Atom

I have a data set that specifies a list of values and the number of times to "copy" them. For example,

 

FruitCopy Num
Apple2
Orange4
Banana3

 

The output set I'm trying to achieve is this:

 

Fruit
Apple-1
Apple-2
Orange-1
Orange-2
Orange-3
Orange-4
Banana-1
Banana-2
Banana-3

 

I looked into the Multi-Row Formula tool but wasn't able to figure out how to go about doing this. Does anyone have any suggestions?

4 REPLIES 4
NicoleJohnson
ACE Emeritus
ACE Emeritus

Try the attached!

 

1. Use the Generate Rows tool to create a new line for every number X-1 until you get to 1

2. Formula tool to concatenate the original column name with the new RowCount # to get your combination

 

Does that work? :)

 

NJ

adm510
11 - Bolide

Use the generate rows tool. Take a look at the example I attached

wvonderrosen
5 - Atom

Clutch!, thank you!

rebekajackson
5 - Atom

Brilliant, I needed a very similar solution - but mine was because the "count" needed to combine with the "unique string" to get a field with "unique string.1,...,unique string.count".

 

I wasn't sure if my data had unique rows so I added a record ID before I duplicated the rows, before including that in the "group by" and "concatenate" steps to get what I needed.

 

Never used the generate rows tool before, very helpful!

Labels