Rule-based Row Filter Help

Hello,

I am new to KNIME and struggling with a similar issue (using rule based row filter in a loop). I am attaching my input & output files as well as the KNIME workflow I am trying to use (have incorporated the workflow shared in this discussion).

I want to loop across multiple columns and filter out a value from each column. For example, in the input file, I want to loop from columns Loc1 to Loc7, filter out the 0’s in each column and return the rows that have 1 & RA in the format given in the output file.

This is the workflow I have created but not getting the desired result.

What I am trying to do here is in the loop End node, I have selected to use the ‘Add Iteration Column’. I have then replaced the iteration column with the locations (Loc1 to Loc7), using a mapping between iteration number and locations. This is to get the format as in the output file but the loop is not generating the desired output.

I am still learning so the approach is a little crude. It would be great if I could get help in solving the above.

Input1.xlsx (9.2 KB)
Output1.xlsx (9.0 KB)

Thanks,
ksg

Hi @ksg and welcome to the forum.

It turns out for this case a loop (and associated flow variables) are not needed - you can do this with a careful application of the Unpivoting node:

Check out this example and let me know if you have any questions: Unpivoting_Example.knwf (33.3 KB)

3 Likes

Hi @ScottF,

Thank you. Did not know about the Unpivoting node. This works great. Thanks for the quick help.

One question, if I use another input file for this workflow where the only variation is the number of locations (like in the example we have columns Loc1 to Loc7 and another file has columns Loc1 to Loc15 etc.), do I have to adjust the Unpivoting node each time? I plan to use multiple such files on the same workflow so thinking of a way where I would not have to adjust the Unpivoting node each time when the number of columns for location change.

Thanks,
ksg

Instead of using Manual Selection in the configuration dialog, you can use Wildcard/RegEx Selection instead to choose, in this case, any fields starting with “Loc”:

2 Likes

Great. Thank you :slight_smile:

1 Like