How to derive a new column depending on how many out of three columns it fulfills

image

The products are able to be categorised into a maximum of 1 category and 2 sub categories. The numbers under each column represent which category they are in. What I’m trying to do is create a new Integer column that shows an integer for each product depending on how many product categories they are in. For eample, 001 will have an integer of 3, 002 will have an integer of 1. How do I go on about doing this?

Hi @mddaysh

Welcome to the KNIME community!

You can use the Column Aggregator node for this. Steps:

  • Add the node in your workflow and enforce the exclusion of the Product ID so that you are only considering the Product Cat x

  • Go to Options, add a Count aggregation and make sure that the Missing field is unchecked.

This will result in the desired count:

image

Hope this helps.

2 Likes

thank you so much, it works! for those products with all missing values in all categories, I need to display a 0 in the Count column, how do i do that?

Nothing different :slight_smile: Is done automatically.

image