Export to multiple excel files by group

I have a table that looks like this:

I can’t quite figure out how to export this table to multiple excel files by group.

(Three files, HR, Accounting, Sales)

Expected result:

I tried to add action “Iterate” and run a sub-module with “Export to Excel” function, but I’m not sure how to pass the filtered table from the main module and how to run export to Excel by group.

Thanks!

You need to use the “Iterate table” action (not “Iterate”). With that action iterate along a list of groups and pass to the iterated module a group (via a parameter) and the full dataset from your upper screenshot. The iterated module must have the “Input” action in order to obtain the dataset from the parent module.

Finally, just use in the iterated module the “Filter by expression” action to keep only rows the belong to the group passed via parameter.

See the “Advanced topics” article from the tutorial chapter on iterations: https://easymorph.com/learn/iterations.html.

Also, see Example #5 from the same chapter.

Alternatively, a simpler but less idiomatic solution would be to use the regular “Iterate” across a deduplicated list of groups and read the full dataset from a file in each iteration in the iterated module, then filter it down to the group passed via a parameter. This variant is slower because it requires reading the same dataset again and again in each iteration.

1 Like