Create a new file for each row filter

Hi all

I am trying to figure out how to create a new excel file for each “Name” in a pivot table. I am pretty new to Knime and don’t fully understand loops yet.

For example, for this data, SUPERVISOR A and SUPERVISOR B should be separate excel files. I was thinking of applying a row filter and creating an excel reader, but there are 20 supervisors.

SUPERVISOR A | EMPLOYEE A | TRAINING PAST DUE
SUPERVISOR A | EMPLOYEE B | TRAINING PAST DUE
SUPERVISOR B | EMPLOYEE C | TRAINING PAST DUE
SUPERVISOR B | EMPLOYEE D | TRAINING PAST DUE

Hi @sroberts , in your case, you should use the Group Loop and group on the Supervisors.

Each iteration of the loop will contain the same group of supervisors, meaning if we take your sample data as an example:
First iteration will have:
SUPERVISOR A | EMPLOYEE A | TRAINING PAST DUE
SUPERVISOR A | EMPLOYEE B | TRAINING PAST DUE

Second iteration will have:
SUPERVISOR B | EMPLOYEE C | TRAINING PAST DUE
SUPERVISOR B | EMPLOYEE D | TRAINING PAST DUE

And so on if you have other supervisors.

You should also check the variables that are available/generated in the loop, such as the group value (“SUPERVISOR A” for first iteration, “SUPERVISOR B” for second iteration in your case), which you can use as a dynamic value for your file name.

Something like this should work:
image

2 Likes

For some reason ‘Path’ is greyed out in this instance.

Hi @sroberts first, I’m gonna take a guess that you are talking about choosing a flow variable as a destination file.

If that is the case, this usually happens if you don’t any variable of type Path. So you need to create that variable. Within the loop, build you string path using the String Manipulation (Variable) and then convert to type Path using the String to Path (Variable)

1 Like

Here’s a workflow based on Bruno’s suggestion.
Supervisor Excel Files 1.knwf (29.4 KB)

2 Likes

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