Counter generation based on values of two columns

Hello KNIME Community,

I am working on generating cardinal numbers based on the values of two columns as criteria.

I extracted the EAN code from the URL of images and the two integer numbers after the letter P as it is shown on the below picture that I included here.

I would like to assign a number to each of those EAN + Image Position column combinations based on the logic as follows:

  1. for rows where EAN column value is the same in the dataset
  2. check values in Image Position column
  3. assign value 1 to the smallest
  4. assign value 2 to the second biggest
  5. assing value 3 to the third biggest etc.

I was tinkering with Rule Engine and Counter Generation nodes but I couldn’t figure out the solution so far.

Can you please advise on the solution if you have already encountered the same problem before?

Thanks,
Zoli

minor modification to the above logic:

  1. for rows where EAN column value is the same in the dataset
  2. check values in Image Position column
  3. assign value 1 to the smallest
  4. assign value 2 to the second smallest
  5. assing value 3 to the third smallest etc.

Hi @zvisnyai,
You can use a Group Loop Start node and set it to group by EAN, then inside the loop, sort by Image Position (Sorter ) and then add a Counter Generation node. Finally, collect your results with a Loop End.
Kind regards,
Alexander

3 Likes

Thank you for the help Alexander.

1 Like

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