Combine switch steps into one execution

Hello all, I have a flow updating data into different google tabs. I used a switch block to divide data into different groups based on Tab name, and then insert them into different tab on Google Sheet individually. I do this step because it can only insert one Tab in Google Sheet step without switch block.

However, when running the flow, it always run six times causing the final email notification step running six times, which I only want to run once. If there any ways to force the final emails step only running once?

Thanks!

It is very likely that you need to aggregate data. Given the context provided the recommendation would be to use Aggregate or Summarize nodes - depending on the data structure you have and the data structure you want.

If you need a better tailored solution please pin some data in your Sheets or Code nodes and paste workflow here using </> button. You can edit pinned data to strip sensitive information.

Alternatively there is literally a node setting to force the node to run only once.

I guess it will only use the first item from the input.

Thanks for your advice, I tried both ways but doesn’t work, maybe I need to modify something about Google Sheet Node so that it can match different tabs in one run…

I tried “Execut Once” but it only works on the first item of each run, and my flow seems run six times, so it would still output six times.
The aggregation node also run six times if added after switch node.

You can append the data with the merge node to bring it all back into one item list

I add it after switch node, in that case, “execute once” does work for only running on the first item, but google sheet is only updating one tab, it seems that in each run & update, google sheet can only choose one tab.

What is the purpose of the Switch node?
Seems like the source data already has information about the Tab to put data onto.
What will go wrong if you get rid of Switch?

If you need only to trigger a single email when everything is done and it doesn’t really matter what data is or how many data is there, then simple “signalling” node will work. Of course, the data should be aggregated before that and arrive in a single batch.

Maybe you wanted to group the input data per tab to put the data on? This type of transformation is also doable. It is that Switch is not an appropiate tool for data transformations.

Purpose of Switch node:
Google Sheet node can only choose one tab to update each time.
Though my data source has a category column deciding which tab the data should be inserted, the Google Sheet node would still choose the first item’s category as the target tab, and then update all data into this tab.

After applying Switch Node, the data is divided into six batches based on category(Tab), each time Google Sheet node choose one batch to update and update them all into the same tab.

If I don’t apply switch, that means all data will be run in one batch, and all 1k data should be inserted into one tab regardless which category it belongs.

So I think my real questions is how to merge different batches into one batch, and let it run only one time in the following steps.

Thanks for reading the long posting and your patience.

I think one last way is setting up 6 Google Sheet node, and direct each batch into one Google Sheet node, then aggregate after updating all data. In that case, all batches will be merged and the steps after that will be run once.

If there is no workaround I think that is the only feasible way right now…

This one valid concern and a solution.

One another option is to employ Loop.

or a sub-workflow that would process items 1-by-1 (write to Google Sheet).

Thanks for so much your advices.

I tried the loop thing, it does work. I might try to find a way merging the switch branches to avoid visit Google Sheet node too many times, if not, your solution is an accessible way.

1 Like

Chances are that with Minimise API Calls option on Google Sheet node it sends data in batches.

Then grouping data per sheet would make sense.
Here is an example I created for myself for future reference. Note that the input data structure is simplified.

If your question has been resolved, please mark my previous post as a :white_check_mark: Solution.

1 Like

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