Copy a row when a certain condition is met

Hi,

I am currently trying to reproduce an Alteryx workflow in which the “Generate Row” is used. Basically, I am trying to duplicate rows that meet the condition ''RowCount<Quantity". The RowCount starts with 1 and increments by “RowCount+1” every time the condition is true. Whenever it’s false it goes to the next row until all possible rows are duplicated. I think I need a loop but what i’ve done so far does not work.

Thank you in advance!

Hi @mediis,

I hope I understand your problem correctly.

First filter for your condition with a row filter

Then append the result with the Concat Node to the original table

All rows with your condition will now be duplicated :slight_smile:

2 Likes

I think it’s a little bit more complicated, the row has to duplicate every time the condition is met, so if quantity is equal to 9, the row will duplicate itself 9 times so the rowcount will incremeny by 1 at every instance, let me show you an example of what is done in alteryx

1 Like

Hi @mediis , and welcome to the Knime Community.

I hope I understood what you are trying to do.

This is my input data:
image

And I put something together that yields this result:

Is this what you are looking for?

The workflow looks like this:
image

Here’s the workflow: Copy a row when a certain condition is met.knwf (20.3 KB)

2 Likes

I’m not quite certain from the screenshot whether this simplified example is on the right lines, but starting with a table such as this:

image

The following table can be generated using the One Row to Many node, with Quantity deciding how many duplicates of the row are required:

image


Row generation.knwf (8.5 KB)

6 Likes

Nice one @takbb . I didn’t know about the One Row to Many node. I knew about the One to Many node, which was not working for this, I thought it was supposed to do One (Row) to Many. So they’re actually 2 different nodes.

Something useful to learn :smiley:

3 Likes

Thanks @bruno29a! I guess it’s an often overlooked little node. Only used it a couple of times myself, but definitely a great little one for the toolset… :wink:

3 Likes

Thank you so much, this did the trick!!

1 Like

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