Count only visible rows in RG

Hey everyone,

I’m struggling with something, and maybe I’m just overthinking after spending so much time on it haha, but here is the situation:

I have a list of brands
Each brand has a list of products
Their is a filter by default to show only products for kids.

So there is the first RG for the brands and another RG inside it for the products (nested RG)

*Brand 1
**Product 1
**Product 2
**Product 1
**Product 2
*Brand 3
**Product 1
**Product 2

When there is no product for a brand, the corresponding brand RGs are hidden.

I want to show a message outside of those RGs, at the very top, saying something like “there is no products available” when none of these Brands have a product and hide everything.

I know how to do this inside the nested RG as it’s easy to count the number of products, but I don’t want to show every RG with this message inside it.

I tried to add a condition like this but it’s not working because it doesn’t count only the filtered results visible, but all the products from all the brands: repeatingGroup All Brands’s List of Brands:each item’s Product:count is 0

So if the page only shows 2 brands with 2 products each because the default filter only allows to show the products for kids, it counts all the products so the result is way more than 4.

I tried to use Repeating Group Tools but I can’t make it work for my use case.

Any idea how i could achieve this?

Thanks! :smiley:

You will get repeating group all brands, filter it by using advanced filter. In this filter, you will filter out the ones where there are no kids brand and finally after the filter, you get the count. That should do it.

Thank you, but I don’t want to use another filter, my app is already showing the products based on many complex filters and conditions, so I was looking for an easier solution like only counting the visible rows. haha

Then, what you can do is: add these data sources to a custom state on page load (and whenever filtered) so you can reuse them in many places.

1 Like

That’s a great idea! I’ll try this, thank you! :smiley:

1 Like