Loop through flow variable

Hello everyone,

I am a bit stuck. My Input data is as follows:

Section | department | other stuff

I have a workflow that works and now I want to apply it to the different departments of a section. Is there a way to use flow variable in a loop? (For each department in of a section do the workflow.)

Further down my workflow I have a similar problem.
Within the departments I have created groups. Each group consists of multiple members. Some members hate each other. I want to remove these members from each group and place these into a new group. It would be nice to remove as few members as possible. Is there a way to determine for each group (if any or) which members should be removed to have as few groups as possilble.
My Input is as follows:

Hatelist: Person1 | Person2
Peter | Sandra
Peter | Mike
John | James
Susi | Mika
Carrie | Joe
Andi | Joe

Groups:
Group | Members
Group1 | Peter, Mike, Mika, Sandra, Toni, Steve
Group2 | John, Sandy, Susi, Andi, Carrie, Joe, James

The desired output would be to remove Peter from group1 and from group2 Joe, James/John. At the moment I am only able to remove the column Person1 or Person2 for all my groups but not individually.
Like in the initial Problem I think a good start would be to loop over the groups and per group determine which column (Person1/2) to use to remove members.

Thank you for your help.

Regards
Sofia

Hi @Shaller,

for this part I would use a group loop start node and group based on the column department. In each iteration of the loop, the workflow would use only the samples for one department. You can then use a loop end node to collect the results for the different departments.

The second task sounds a bit more challenging. Especially finding the optimum solution (as few as possible).

One approach could be:

  1. Loop over the different groups.
  2. Find out which person hates most of the people in this group and remove him.
  3. Continue until only people who like each other are left in the group
  4. Put all people you removed into the next group
  5. Do the same for the next groups until you have only groups of people who like each other.

Would a workflow which performs these steps solve you problem?

Best regards,
Kathrin

2 Likes

Hello @Kathrin,

Thank you for your suggestions. They are very helpful.

The group loop start works really well. However I have realised that it is not possible to have multiple ends. My workflow starts with one Datasheet, but then branches out as I obtain multiple different informations from it. Is there a way to solve this problem?

Secondly,I like your algorithm for the people hating each other and came to a similar conclusion. However I am having trouble transfering these thoughts into nodes. How can I “Find out which person hates most of the people in the group” in terms of nodes?

Than you for your help.

Regards
Sofia

Hi Sofia,

sorry for the late reply!

A loop always needs one loop start and one loop end node.
The idea of a group loop start is to apply the same transformation to subsets of the dataset. If you want to apply different transformations to different subset, you can use the row splitter or the rule based row splitter node to create two subset, where for each subset of these two subsets you want to apply the same transformation. If this doesn’t solve your problem it would be great if you could describe your problem a bit more in detail.

To find out which person hates most of the people in the group you can use a combination of a joiner node, a groupby node, a sorter and a row filter node. This is an example workflow for this task.
Forum_Loop.knwf (15.8 KB)

Best regards
Kathrin

1 Like

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