Using a loop to create more columns.

Hi Forum, I would please like some assistance with an issue I am having.

I have the following table:

ID Category
Row148 History
Row149 Change Event
Row150 Share
Row151 History
Row152 Share

I would like to add a new column for each unique value in the Category column and then assign a 0 or a -1 to the row in the new column depending if the value is present in the Category column. So the final layout that I want would be:

ID Category History Change Event Share
Row148 History 0 -1 -1
Row149 Change Event -1 0 -1
Row150 Share -1 -1 0
Row151 History 0 -1 -1
Row152 Share -1 -1 0

Any assistance would be greatly appreciated.

Hi @Tjaart , have you tried the One to Many node?

This I think will generate 1 (present) and 0 (not present).

If I understand correctly from your screenshot, you want 0 to mean “present” and -1 to mean “not present”, which is unusual, but ok…

Follow it with Math Formula (Multi Column) and give it the formula:


btw, welcome to the KNIME community! :slight_smile:


Thank you very much @takbb! This worked.

You’re welcome @Tjaart . Glad to hear it worked for you.

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