How do you "get" the filter value?

Hey there,
I have a filter set up after a module. Let’s say the filter lets through 18 items from the previous module, how do I “get” the number 18 and use it as a variable?

The use case: I want to count the number of items in a Webflow CMS collection that matches a given criteria.

Many thanks
Jacob

Hi @Jacob1 there are different ways to achieve this, if the resultant bundle is an array, you can use the length() function. Can you share a screenshot of the filtered result/bundle?

Hi there, thanks for reaching out,
Here are two screenshots. In this case I want to add the number 41 in column B of my Google Sheet.


I wouldn’t try to do this by counting each individual matching item. That could burn a lot of Make operations.

The Webflow List Items module is iterating over every Webflow item that matches the parameters.

I would explore the possibility of then using an aggregator to create a single array of all your Webflow items, and then using the map() function to create an array that contains only the collections that match the criteria you’re currently filtering for.

Then, to find out how many match you’d simply use the length() function to count the number of entries in the new array.

The result would look something like this (NB - I’ve not tested this so you may need to make further tweaks!):

1 Like

As @DavidGurr_Make suggested you could use an array aggregator just after the filter, this will return an output bundle called “_IMTAGGLENGTH” which contains the count of the filtered items

output of array aggregator

after then, you can use an iterator to get back all items so you can iterate through on to google sheet

sample result

then you can further use this variable as you choose to

1 Like

@Emmanuel_Momoh I like your solution better!

As is usual with Make, there’s many ways of cracking the same problem.

1 Like

Hey again, many thanks for your input.
I started with trying @DavidGurr_Make 's solution, and it worked like a charm. See below.

Just a related question: What if I’m filtering for an amount (I am), and I’d like to summarize all the 41 amounts into a total. Any idea how I can achieve this?

Thanks again, very helpful,

When you say “summarize”, do you mean the total of all amounts of the matching items?

Yes exactly, let’s say I want to use the value 30,000 below.

Matching item #1: $10,000
Matching item #2: $10,000
Matching item #3: $10,000
Total: $30,000 < --------

For that, you’d use the sum() function which sums the values in a simple array.

You’d first need to create that simple array that contains just the values you’re interested in. If, for example, the value element in the Field Data array is called value, then this should do it:
sum(map(2.Array[] ; fieldData ; value))