Repeating string value by order

Hello Team !

After 2 hours of searching i’m posting my question, this is my data set :

1|Date |2020-01-03|
2|Toyota |0,00|
3|Yaris|0,00|
4|Mercedes |2 122,20|
5|Fiat|0,00|

6|Date |2020-01-05|
7|Toyota |0,00|
8|Yaris|0,00|
9|Mercedes |2 122,20|
10|Fiat|0,00|

and i would like to insert a column with the date in the first column each 5 raw to have this :

1|Date |2020-01-03|
2|Toyota|2020-01-03
3|Yaris|2020-01-03
4|Mercedes|2020-01-03
5|Fiat|2020-01-03

6|Date |2020-01-05|
7|Toyota |2020-01-05|
8|Yaris|2020-01-05|
9|Mercedes|2020-01-05|
10|Fiat|2020-01-05|

Thank you a lot for your help ! :slight_smile:

1 Like

Hi @Remouters & welcome to the KNIME forum!

Would this be near the expected result ?

20210629 Pikairos Repeating string value by order.knwf (52.4 KB)

Hope this helps :wink:

Best,

Ael

4 Likes

Hi @aworker I like that solution!

I was going to number each set of 5 rows as a unique “block number” using a Math Formula:
floor(($rownumber$ -1) / 5)

assumes row number starts at 1 and is sequential!

then use Row Splitter to filter off the Date row and apply the “date” to each block to the other rows in the block using a Joiner (on blocknumber)… then concatenate back the “date” row with the remainder of the block, rename some columns, resort, tidy up etc… and 10 nodes later it would have been there! :wink:

… but yours is much more succinct and doesn’t need to pre-know the number of rows in the “block”.

2 Likes

@aworker Thank you !!! very smart solution.

Thank you also @takbb for you help

2 Likes

Thanks a lot @Remouters and @takbb for your kind comments !

Have a great day

Ael

2 Likes

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