Pick first n values from a different values column

Hi all

i d like to ask a question, sorry for my bad english and my poor knowledge of Knime

I ’ m trying to solve a wf wich allows me to pick the first n (e.g.4) values in a column depending on another column. I post a table to explain better

as you can see, i would like to pick the first 4 rows ( or only the values of the column “Ordine…”) of the column “Itinerario” for each different values. For example i d like to pick the firsts 4 rows of value 33000F, the firsts 4 rows of the value “33000G” etc.

I tried with rank node and top k selector node but it doesn t work. Anyone may help me???

Thanks in advice!!!

Cheers

i think it s solved with a group loop nodes.

image

thanks in advice

Bye all

2 Likes

Hi @Pippobaudo89 ,

Glad to hear you found your own solution. And thank you for sharing it to the public.

While the group loop nodes are spot-on, I just want to caution the use of the top-k selector for this particular case.

The node automatically sorts your “Ordien…” column values either in a descending or an ascending manner. It seems that you didn’t mention anything about sorting, and only cared about “the first 4 rows”. If what you meant was the first 4 rows as they originally appear like you showed in the screenshot, then a more suitable node to replace the top k-selector is the Row Filter Node with the following configuration:

The Group nodes stay as they are.

You might want to revise the outcome of your workflow, so that the “first 4 rows” you get correspond to what you really want - unsorted vs sorted.

2 Likes

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