List intersection limitation with Bubble Option Sets?

Hi Bubblers,

Hitting a brick wall regarding a repeating group. I have trawled forums but everything I am seeing or reading doesn’t seem to work with my use case.

Basically, I have a library of workouts. Some of these have workouts require specific equipment. On my User, they have inputted which equipment they have.

I want to filter the list of Workouts based on that Users equipment list. The equipment list is an option set.

Some Workouts have no equipment so these should be returned as well.

Here is the tricky part. If a workouts equipment list contains some of the users equipment but not all, it should not be shown.

So, if a users equipment list is: “Dumbbells” and “Kettlebell”, the results should be as follows

Workout A: Requires Dumbbells
Workout B: Requires Dumbbells, Kettlebells
Workout C: Requires Kettlebells
Workout D: Requires Bench
Workout E: Requires (empty)
Workout F: Dumbbells, Ball

As a result, the list returned should be:

Workout A: Yes (Dumbbells is found in user list)
Workout B: Yes (Dumbbells, Kettlebells are found in user list)
Workout C: Yes (Kettlebells is found in user list)
Workout D: No (Bench is not in user list)
Workout E: Yes (No equipment required)
Workout F: No (Dumbbells is in user list but Ball isnt)

Part of me thinks I need first filter the list and get the results of all the equipment aspect and then I just merge this with a list of all the empty equipment workouts.

Struggling on all fronts with this though as the deeper I get into filtering using “Advanced” for example, no option sets appear.

Any ideas community?

Hi, I had a challenge that is similar to yours in that I am trying to filter a list of entries with a list of subjects in an option set. I suppose if your dataset isn’t huge, you could generate repeating group lists on your page, and then search based on those and/or use the intersect with function.

I ended up using advanced filters, with help from this post: Searching using multi dropdown - possible/alternative? Incompatible type

Note when using advanced filters and “intersect with”, the “:count” function is essential since that’s how you determine how the two lists should line up. Regarding your goal to only return results that contain all of the user’s equipment, in the advanced filter I’d try something along the lines of searching for Workouts and using an advanced filter like… “Advanced: This User’s Equipment intersect with Workouts’s Equipment:Count >0 and This User’s Equipment:count [greater than or equal to] Workouts’s Equipment:count” I may not have written this 100% correctly but that’s the overall idea.

A warning though, advanced filters are not fast if your dataset is large. I was back and forth with Bubble support to confirm that there wasn’t some way to do this search on the server side, and they said no.

1 Like

Note when using advanced filters and “intersect with”, the “:count” function is essential since that’s how you determine how the two lists should line up.

^ A crucial piece!

I was able to create the correct expression from your suggestion. I will monitor speed but hopefully it shouldn’t be too much of a trade off.

Thank you very much!

That’s great, glad it worked!

1 Like