Filtering Out Duplicates in a Repeating Group, Based on Parent Data

Hello everyone! I can’t seem to wrap my head around how to remove some duplicates, and thought I’d see if anyone else can approach this a different way.

I have a list of restaurants. Each restaurants has a list of locations. Each location has a list of meal deals.

When the page is loaded, I set a state that is a list of all the restaurant locations within 30mi of the current user’s location. When they’re using the app, they see a repeating group of that custom state’s meal deals.

Here’s my question:

How do I filter this list of meal deals to only show deals from the closest restaurant, even if there’s multiple locations?

This becomes an issue when there’s 5 Burger King’s in your area for example, and you see the meal deals repeated 5 times. I don’t think I can use :unique elements, as technically they are all unique. I’ve thought about approaching this by using :intersect with or :group by, but haven’t had any luck.

Thanks for your time, and any input or ideas are much appreciated!

Hey @callen.hedglen

I’m wondering what happens after these meal deals are displayed? If you did not remove duplicates, then the user could click on the deal and you would take some relevant action specific to the meal deal they choose. But since you are looking to remove dupes, Am I correct in thinking simple text display (rather than a meal deal thing) will suffice?

If so, the group by modifier should work. What trouble did you run into? You should be able to do a search with your constraints, then: group by and select the field that is common across them all.

1 Like

How do you know they are unique ?

I would have thought you would be able to set up the “meal deal” as being a single thing, and then having another data type that is a list of deals+restaurants intersections (so the many-to-many).

That way unique on “meal deal” would work.

1 Like

Thanks @mebeingken and @NigelG for helping me out with this!

After looking at both of your answers, I added a text variable to my meal deals called grouping-name. All of my meal deals had this variable added, which was in the format [restaurant] - [meal-deal-title]. I then went to my repeating group, and use the :grouped by modifier to group by the grouping-name.

This seemed to work intermittently, with probably about half of my deals getting grouped properly - it also seemed like I can’t sort the RG after I used :group by. I triple-checked to make sure the grouping-name was the same for the deals to group. Any ideas on this behavior?

@NigelG, could you explain a bit more how I could approach this differently and set up the intersecting searches? I guess I’m just worried about page speed when having to search through a lot of data again - I currently do the initial searches on page load and store in custom states, and filter those results for various parts of the app.

Thanks!

Also, here’s a screenshot to get a better visual.

Update: I looked deeper into my data, and found 2 grouping names that didn’t match :slight_smile: Fixing that removed my duplicates and solved my problem!

1 Like

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