Filter a Repeating Group with Conditions

Hello,

My app shows restaurants that a company can order catering from. I have a repeating group with a nested repeating group and I’m trying to filter it so that if the company is less than 30 miles from the kitchen and the company headcount is > minimum headcount for kitchen (less than 30 miles), then those restaurants will be filtered to show in the RG.

There is a separate minimum headcount that kitchens set for over 30 miles that would use the same logic as above.

Here’s a link to the editor: WowCater | Bubble Editor

Hi David, I hope you’re having a great day!

I took a look at your app and wanted to help you with the issue you’re facing. Firstly, let me say that I’m impressed with your web app; it’s great to see what you’ve built!

To filter the restaurants based on the company’s distance from the kitchen (less than 30 miles), you can create a custom state for the Repeating Group called “distance.” When the user sets the filter, you can set the “geographic address of the current company” in this state. Then, in the data source for the repeating group, you can add a constraint like this: “(company’location distance from RG’distance < 30).” This should effectively filter the results for this criterion.
And this tutorial will help you in calculating the distance: (How To Calculate The Distance Between Two Points In A Map (Bubble.io Tutorial) - YouTube).

For filtering the restaurants based on the company’s headcount being greater than the minimum headcount set for the kitchen, you can create another custom state for the Repeating Group called “headcount_number.” When the user sets the filter, set the “current headcount of the restaurant” in this state. Then, in the data source for the repeating group, add a constraint like this: “(company’headcount < RG’headcount_number).” This will help you filter the restaurants accordingly.

I hope these solutions help you solve your problem. If you have any more questions or need further assistance, feel free to ask. Best of luck with your app!

1 Like

Thank you! Sorry for the delay I’ve been sidetracked for the last couple weeks.

However, the distance < 30 is only filtered out only when company headcount is < RGheadcount.

The logic above doesn’t seem to account for only filtering distance based on headcount criteria but I will give this a try.

This topic was automatically closed after 70 days. New replies are no longer allowed.