Problems with dyanmic filters

What are you trying to achieve?

Hi guys,
I am seeking your help to solve this dyamic filtering problem.

I am basically trying to achieve the following flow between the Google Sheet - Search Rows and the Google Drive - Move a File/Folder:

  1. Filter above → “Customer 1” contains the word “Customer”? Yes, move to the Customers folder
  2. Filter below-> “Customer 1” contains the word “Contract”? No, do nothing
  3. Filter above → “Contract 1” contains the word “Customer”? No, do nothing
  4. Filter below-> “Contract 1” contains the word “Contract”? Yes, move to the Contracts folder

but what I am getting is the following:

  1. Filter above → “Customer 1” contains the word “Customer”? Yes, move to the Customers folder
  2. Filter below-> “Contract 1” contains the word “Contract”? Yes, move to the Contracts folder
  3. Filter above → “Customer 1” contains the word “Customer”? Yes, move to the Customers folder
  4. Filter below-> “Contract 1” contains the word “Contract”? Yes, move to the Contracts folder

Thus executing a number of useless operations.

To test this I have created a master folder containing:

  • Contracts and Customers subfolders
  • 2 files, Customer 1.docx and Contract 1.docx

There is also a spreadsheet, searched with the Google Sheet - Search Rows module, that cointains Tag-FolderID pairs.

Thanks in advance for your help!

Screenshots: scenario setup, module configuration, errors


Hi @Frost

Are your folders going to grow in number? I mean, will you add new Tag/Folder ID pairs to the sheet and add more folders?

If that is the case, you can use the result from Google Drive Watch Files, read the Tag/Folder ID for each file in the spreadsheet, and go straight to a single Move Files module, mapping the folder ID to the destination. No Aggregation, Iteration or Routing needed.

Watch Files → Read Folder ID filtering by tag → Move File to Folder

But if you only have 2 folders (Customer and Contract) and that’s all, just go straight from Watch Files to the Router. Hardcode the filters (1st “Customer”, 2nd “Contract”) and hardcode folder ID in both Move Files modules.

@damato

Hi @damato

I want to allow the system to scale in terms of Tag/FolderID pairs so I can’t hardcode the filter/router.

If I remove the aggregator, the Search Rows module is uselessly triggered multiple times.

I am trying with this new configuration below but still having problems with accessing the i-th element of the array.

Hi @Frost

Maybe you got the Aggregator wrong. The first module returns a bundle for each file found. That is why you have to query google sheets for each file found.

When you aggregate, you are telling Make: “Hey, please gather all these bundles from the referenced module repeatedly and put them all in an array, so I can do a single operation on the array.”

That’s why you only have the option to reference an item in the array by its index. That’s not useful in your use case, since you don’t even know how many items are there in the array. You could add an Iterator, but what would be the point to aggregate and them iterate again, if you are already iterating from the 1st module? (Sometimes you do need to do that for grouping, but that is a totally different subject.)

If all you have is an array, how will you be able to match each file with its corresponding Tag/Folder ID?

Your simplest option is to let your flow query Google Sheets for every file.

Or you can try to load all rows from the spreadsheet before reading the files (I believe you would have to use Search Files in regular intervals, instead), save the Tag/Folder ID pairs to a variable, and get the correct value for each file inside the filter.

Unless you have several thousand files to process, the complexity of this solution would overpower the gains and generate marginal economies in operations.

In my experience, Make is a great tool to build stuff fast. Once you start trying to over-optimize things, especially from the beginning, it becomes unproductive.

@damato