Variable loop to replace data populated with null

I am trying to get this loop to replace data within 3 columns if the schoolCheck is N. With the current set up it is working on daysAbsent only, when I execute the Variable Loop End, it then only works on attendanceAbove90Perc. When I step through the Variable Loop End it only nulls a single column.

Haven’t done much with loops in this regard, but if I can nail this down would be a very valuable tool in my toolkit, what am I missing here?

Appreciate any and all help

kn_example_replace_values_loop.knwf (1.9 KB)

edit: Some context behind this, I was given a data set that I need to join based on a concatenation of first and last name, as well as matching birth dates and school. Some students are matching but are not in any of our schools, which are the schoolMatch N students. I have already lambasted the stakeholder about not providing unique ids.

Hey there,

I just downloaded your workflow - thanks for thinking ahead and uploading it!

I’m afraid it seems to be empty … Can you try uploading again?

Edited the initial post with the correct file.

Really sorry it is still empty… Also “unzipped” it to check and there is indeed nothing in it… which version are you on? If you navigate to your knime-workspace: what do you see inside that workflow? any other folder other than “artifacts”?

I’m on 5.2.5 here’s what I am seeing in the workflow folder.
image

I swapped to the old interface and exported from there, just in case.

kn_example_replace_values_loop.knwf (83.9 KB)

Looks like my edit of the new file didn’t actually save. This one above should work though.

That worked now :-).

First of all it really looks like you already know what you are doing!

I also managed to identify the cause of only one column seeming to work.

It is actually that your rules etc. perfectly work - the only thing is that each rule is always triggered on the original dataset.
That’s why you only get to see the effect the last rule in your table had.
I.e.: Your first rule is processed, the result of your main table is discarded the moment that the next iteration fires as the dataset in the state of your first Rule Engine Node is being used again - w/o the modifications of any previous iteration.

I thought about how to solve it - one pathway could have been recursion - however as this is not too intuitive I tried a Column List Loop:

Overview:

Comments:
I split your initial table (starting from first Rule Engine Node): Upper Port only the five columns required for processing (so the three that the rules are applied to + the two that are referenced in your rules).

The Column List Loop node is then configured to include schoolCheck and that dummy column in every iteration and to then only include the other columns in individual iterations. So that means we have in each iteration three columns: schoolCheck, dummy and one of the three other ones.
As the name of the column that is only processed each iteration is by default exposed in a flow variable I use it to filter your rule table for the name, turn the outcome into variables and then proceed with your rule engine node.
I filter out schoolCheck and dummy in each iteration (otherwise you end up with three of them each in loop end) and after the loop end it is about adding back the columns that are missing…

Here’s the prototype:

kn_example_replace_values_loop.knwf (128.3 KB)

1 Like