Hi there,

I can’t seem to find the right node to perform a simple conversion of “one row to many” with total from one row being equally shared across several rows, i.e. math “divide”.

Example: In a table, I’d like to replace one row for 5 copies of the same book (title, author, publisher, purchase date, etc.) and total purchase price of 100 by 5 separate rows with the same description and a purchase price of 20 for each of them. Can you please point me in the right direction? Thank you.

Hi @RoBex7,

Welcome to the KNIME Forum! What you are trying to do is certainly possible, but not with a single node. I have uploaded a workflow for you here. What it does:

- Loops through the data by multiplier. I.e. all rows with the same multiplier are treated in the same iteration. We could also loop row-by-row, but we can also handle all rows with the same multiplier together by having them in one table and then multiplying the whole table. This makes it a bit faster.
- Inside the loop, we create a table with no columns and a number of rows that is equal to the multiplier. Then we cross join this table with the original table to get the “spread-out” or “multiplied” table. We could use a loop for this as well, but that would be slower.
- Then we divide the numeric column by the multiplier.
- In the end we collect all rows using a Loop End node.

I hope this helps!

Alexander

2 Likes

Hi

next to @AlexanderFillbrunn great solution,

have you tried

One Row to many node and then a math (division) to get the result

br

1 Like

Oh my, there is a node!?!

2 Likes

Hi, there are…

I lov knime… always make new changes…

Tks,

Denis

Hi Alexander & Daniel,

Thank you both very much. Both suggestions work like a charm.