copy rows based on column value & label in ascending order

Hi all

Two tasks I want to accomplish – duplicate rows and labelled with an ascending number.

I have a table like so:

D1 | D2 | Start | End | Duration
D1A | D2A | 2 | 4 | 3
D1B | D2B | 6 | 7 | 2
D1C | D2C | 5 | 7 | 3

I would like to make it look like this:

D1 | D2 | Start | End | Duration | Cycle
D1A | D2A | 2 | 4 | 3 | 2
D1A | D2A | 2 | 4 | 3 | 3
D1A | D2A | 2 | 4 | 3 | 4
D1B | D2B | 6 | 7 | 2 | 6
D1B | D2B | 6 | 7 | 2 | 7
D1C | D2C | 5 | 7 | 3 | 5
D1C | D2C | 5 | 7 | 3 | 6
D1C | D2C | 5 | 7 | 3 | 7

So the integer value in Duration column corresponds to number of row duplicates, and another row I call Cycle is added which ascends from the Start value to the End value.

I’ve tried a number of ways but can’t crack this one. Any assistance at all much appreciated.

Thanks, DoC

Hi @dav1b,

that’s a really funny task you want to accomplish. I think i cold solve it by using two nested loops and flow variables. The result looks like this.


Basically what happens:
1.) Chunk Loop to get one row at a time
2.) Get the value of the Duration column to set the number of times, the counting loop start node should iterate.
3.) Get the Current Iteration Flow Variable from the counting Loop start node and add the value of the Column start with a Math Formula Node.
Here is the workflow i created. Given your example it should be what you were looking for :slight_smile:
DublicateAndCount.knwf (21.6 KB)

3 Likes

Thank you, @MH!

Exactly per my request. And I learned about nested loops. Appreciate your assistance!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.