Execute a module on the last bundle only

When asking your question, please include:

:footprints: The steps you have taken
:camera_flash: Relevant screenshots
:link: Any links you have

My scenario grabs a large number of bundles from a google sheet and filters out most of them, then iterates through the rest. I need to add one module at the end that runs only after the last bundle is processed. I can’t use the pre-filtered number of bundles to accomplish this because of the filter.

I found one solution, array aggregator > set variable to length(array) > iterate through all bundles > filter to bundle # = array length > run final module.

This works well but it’s complex and will be annoying to update and troubleshoot. Are there any better solutions that don’t require aggregation then iteration? Or is the aggregator the only way to perform an operation across all bundles?

Hi @mperez ,

Just set a filter “Bundle order position” = “Total number of bundles” :grin:

Hi Ioic, that method doesn’t work for me. The only module prior to the router is “googlesheet get range values” and that’s before the filter, so the total # of bundles is far greater than the actual # of bundles that will be processed.

Make doesn’t give me an option for pulling the number of bundles from the router step, but theoretically that would work.

It is hard to tell without seeing your actual scenario but you could have a router after your Google Sheets module, the first branch is your current branch and the second branch only runs on the last bundle. This only works if you don’t need the data from the filtered bundles.

I found one solution, array aggregator > set variable to length(array) > iterate through all bundles > filter to bundle # = array length > run final module.

By the way normally if you have an aggregator with the google sheets module as the source you should only get one bundle as the output without any complex data manipulation.

Don’t hesitate to share some screenshots :wink:

Sorry for the delay. Here is an annotated screenshot. Hopefully the resolution isn’t compressed.

This is where I ran into the issue:

This is the solution that works, but I don’t love it because the additional complexity makes it more brittle and harder to troubleshoot. In this version I aggregate after Filter #1 and use the Set Variable to create a post-filter “bundle_count.”

Thanks for your help!