How to fill out columns with specific number patterns

Hi!

I would need to add two new columns to my dataset:

Column 1: Have the same value for three rows then add +1, e.g:
n
n
n
n+1
n+1
n+1

Column 2: Add numbers from 1 to 3 constantly to rows, e.g.
1
2
3
1
2
3

Below is a picture of what i’m trying to achieve. I guess column expressions could do the job, but I haven’t figured this it out and any help would be much appreciated!

Thanks,
Ilkka

image

Hi @Ilkka

See this KNIME_project.knwf (25.9 KB)


gr. Hans

3 Likes

Hi @HansS

Thank you for fast reply that solved my problem!

Best,
Ilkka

2 Likes

Hello!

Not a loop fan so here is a bit of math do deal with above request.

FunnyMath

Check it out here:

Welcome to KNIME Community @Ilkka!

Br,
Ivan

3 Likes

Thanks @ipazin for sharing, very interesting way to avoid looping!

1 Like

It’s amazing what kind of cool solutions you guys come up with.
Depending on your dataset size you can use a crossjoiner (sorry only works for your second column )

2 Likes

Hello,

here is a bit generalized workflow to get repeated sequences and/or Grouping column using Math Formula node:

Br,
Ivan

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