Forum Academy Marketplace Showcase Pricing Features

Multiple Filters to Refine Repeating Group

Hi Everyone,

I’ve spent several days trying to figure these filters out and haven’t been able to get the logic right. In sifting through the forum I’ve found tons of examples which I’ve tried to replicate but they’re all a bit different from what I’m looking for / my setup. Hoping someone can help.

I have a data type - movieEntry. Each movie entry has Genres, Streaming Services, Ratings, and Release Years associated with it.

I’m trying to build filtering so that users can filter/sort on any or all of these things.

  • On page load, I’d like to display all movies.
  • If a user selects multiple Genres, I’d like it to be an OR (i.e, horror OR comedy)
  • If a user selects Streaming Services, I’d like to be an OR (i.e. netflix OR hulu)
  • As the user selects other criteria, that would be an AND - so user wants to see movies that are Horror OR Comedy AND available via Netflix AND rating of at least 5.5 AND Released after 2010. If the user applies a Sort after applying their filters, I’d expect it to simply sort the filtered results.

Any help would be very much appreciated!! Thanks in advance. Below are the links.

1 Like

@fayewatson I’ve read a ton of your posts and you seem to know your way around filtering - any help would be greatly appreciated!

Hi @arrev :slight_smile: Happy to take a look at this! And you’re exactly right, this is trickier to set up with many “OR” possibilities!

There are a few different methods for querying the data. With smaller amounts of data I would recommend using merged searches, but it may not be the best approach for your app since you could have thousands of movies in your database, and running many merged searches multiple times every time a User changes the filtering will eat up a lot of capacity.

One alternative is to use advanced filtering on the search for Movie Entries, but filtering can be really slow when you have a ton of entries in the database as well. It is probably worth considering to restructure the data, and create new data types for “Genre”, and “Streaming Service”, and within each of those data types, you could have a list of Movies field (which stores all of the Movies in that Drama, or available on that Streaming Service). I’ve set up an example here:

Editor:

Preview:

The data structure is set up in this way:

Genre data type:

Streaming Service data type:

Movie data type:

For example, if you created a Streaming Service thing for “Netflix”, that thing’s List of Movies would contain all of the Movie Entries that Users can watch on Netflix:

And if you created a Genre thing called “Drama”, that thing’s List of Movies field would contain all of the Movie Entries that are a Drama:

Within the Movie data type, we would also store the Genres and Streaming Services for each Movie there:

Back on the page, the filters are almost the same as what you currently have (with the Multidropdown data sources being modified to search for Genres and Streaming Services):

Genres:

Streaming Services:

Then the repeating group expression for all of the selected Streaming Services and all of the selected Genres would be:


Here we’re first telling Bubble to find all of the selected Genre’s lists of Movies, then intersect them with all of the selected Streaming Service’s lists of Movies.
By doing this, we’re asking Bubble to display all of the Movies that are the same in both lists.
The “intersects with” operator takes two lists of Things, and returns the entries that are found within both of the lists. This is needed because we want to show the Movies which are of the Genres that the User has selected, and also make sure that the Genre’s Movies are available on the Streaming Services that the User has selected.

Then, filter the Movies by making sure that each Movie’s rating is greater than the Slider Input’s Rating value, and that each Movie’s release year is within the range of the Slider Input Year range of numbers.

An example would be that here the User has selected that they want to watch a Comedy on Netflix:

Airplane! is also a Comedy within the database, but since it’s not on Netflix (only Amazon), so it isn’t shown above. If the Current User then selects Amazon, it changes the Movie results to show both Movies:

Then let’s say we add Drama as well:

This shows all of the results :slight_smile:

Last but not least! We need to add conditional statements to make sure that the repeating group displays all of the Movies when the Current User hasn’t selected any Genres, or has selected Genres without Streaming Services, or has selected Streaming Services without Genres, and sort them all by Release Date or Rating.

In the first conditional on the repeating group, we’re telling Bubble “This is what the Repeating Group data source should be, if the Current User has chosen to sort the results by “Highest Rated”, and has selected at least one Genre and at least one Streaming Service from the Multidropdowns”:

There are 7 other conditional statements which change the data source depending on what has just happened on screen:
2. The Current User has chosen to sort the results by “Highest Rated”, and has selected only Streaming Services
3. The Current User has chosen to sort the results by “Highest Rated”, and has selected only Genres
4. The Current User has chosen to sort the results by “Newest Release”, and has selected Genres and Streaming Services
5. The Current User has chosen to sort the results by “Newest Release”, and has selected only Streaming Services
6. The Current User has chosen to sort the results by “Newest Release”, and has selected only Genres
7. The Current User has not chosen to sort the results and has not selected any Genres or Streaming Services, so all Movies should be displayed
8. The Current User has not chosen to sort the results by “Highest Rated” and has not selected any Genres or Streaming Services, so all Movies should be displayed

And that should do it! :slight_smile: Feel free to let me know if you have any questions!

34 Likes

@fayewatson, I’m amazed there hasn’t been any comments yet on how awesome and thorough this guide is! You made my day with this, thanks a bunch!

8 Likes

Aw! So glad to hear it was helpful! Thank you so much for the kind words @callen.hedglen! :relaxed:

4 Likes

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