Conditional deduplication in repeating groups

Hi All! I am new to bubble (a few weeks ago) and would appreciate any help on how I can conditionally remove duplicates from a repeating group.

I have data that is compiled from multiple vendor websites. The websites tend to appeal to different age groups but some products are sold across multiple sites. The products are therefore duplicated in my database (according to how many times they appear on different sites). I need to remove the duplicates and display a list of unique products in an RG, but I want to select a specific record (along with the description from the vendor site) that is most suitable to the user - ie if the user’s age is recorded as 18-25 they should be presented with a description from one record in the database, and a user who is 45-55 (and searching for the same product) should be presented with a different unique record in the database, rather than the one presented to the 18-25yo.

Just to complicate matters - if a user hasn’t provided their age it needs to present the unique record relating to the vendor that I have previously determined and recorded in a separate table.

Many thanks in advance!

anybody? :frowning:

Hm… I’m not sure I can present you with a complete solution, but from what you’ve described it sounds like you’ve got three questions here:

  1. How to filter RG items to unique only
  2. How to conditionally display descriptions in RG
  3. How to conditionally display RG list items of a different Thing type

The first item should be doable by adding the :unique modifier at the end of the search for items to be displayed in the repeating group.

As to the others, I’ve found conditionals are best handled by having two objects sitting in the same xy space in the layout, both set to not be visible on page load, with a condition that they be visible when the criteria you want are met. So for question 2, you’d have a text object called “Description 18-25” (or whatever) whose condition says If current user’s age is >= 18 and current user’s age is <25 (or whatever the exact range is you want to set up), then This item is visible. And another called “Description 45-55,” etc.

A similar setup should work for question 3, if I’ve understood it properly. Hope that helps!

Hi rmorgan

Thanks for responding. It’s my first forum post (although by no means the first problem I’ve been trying to resolve!!) I’m new to bubble (or at least I’ve been doing it for a couple of months but still just find it a confusing mess, and I feel considerably dumber for the experience!) so I struggle a bit with the terminology, but unless I’m mistaken your item 1 isn’t possible unless the whole record is is a duplicate rather than just one field? So unless I’m mistaken, bubble falls at the first hurdle anyway.

I understand what you mean by 2, but don’t really understand what 3 is about.

I understand what you mean by “having two objects” but I don’t know how I would do this in a repeating group. When setting up a RG it references the data - so I don’t know how I would make multiple records appear in the same RG cell in order to add conditions to hide some records but not others.

Anybody?

can anyone point me in the direction of resources regarding conditional contents for RGs?

Lets start with this…
If you share screenshots of your editor, including the datasource of your RG as well as your data structure, the community can be better informed on how to solve your problem.
Or even better, share a link to read only access to your editor.

Is that link adequate?

You need to grant read access in settings.

Think I’ve done that now. I set it so anyone can edit - This is only a test case to help me understand how to do the data manipulation so I’m not precious about anyone messing with it

In your data set, what fields (“things”) in the Shoes Data Type are you trying to find unique values on?

there are four entries in the shoes thing. three of those entries have the same value for uniqueid. Only one of those three should be visible in the shopfront page.

For the (only currently registered) user, they should be able to see two items on the shopfront page:vendorid FX1334 and 23498067 - the former because it is the only entry with the uniqueID bbb222, and the latter because it has a vendor value that matches the users favouritestore. Other entries should be hidden because they are duplicate uniqueID values.

If for example the users favourite store was “ebay” they should see two items in the shopfront page: vendorid FX1334 because it is the only entry with uniqueid bbb222, and vendorid JkTGzADv
because the user’s favouritestore was not one of the three vendors with the uniqueid aaa111, so the choice was therefore referred to the defaultviews thing where it selected vendor:nike as it had the lowest value for priority and did exist in the list of vendors with uniqueid aaa111

Have you tried doing a search along these lines:
Search for items with count = 1 of uniqueID merged with search for items where vendor value = vendors fave store?

I can’t see an option for count in the search constraints?

Here is the syntax for the main search:
Screen Shot 2020-05-18 at 5.23.06 AM
(Think to replace my UserMatches with your Shoes)

Then the :filtered looks as follows:
Screen Shot 2020-05-18 at 5.23.31 AM
(Think to replace my matchNumber count = 1 with UniqueID)

Then the second search after the merge is straight forward:
Screen Shot 2020-05-18 at 5.23.47 AM

I’m not 100% certain this will work, but give it a try. Your other option which will certainly work is to do this:
Add a yes/no Thing to your Shoes data type called something link “uniqueShoe”. Then when you load a new record, do a search if that UniqueID already exists. If the uniqueID exists, set uniqueShoe to no for the new record and all existing records. If the uniqueID doesn’t exist then the new record’s uniqueShoe = yes.
Then you can do your first search above before the merge for uniqueShoe = “yes”

One additional thought:
The advanced filter can get REALLY slow as your data type grows (any search within a search is highly inefficient). If you’re going to have many records (like in the 1,000’s) then you should absolutely go for the second approach anyway.

thanks for the suggestions but I can’t get the first one to work, and I don’t think the second one will correctly identify which duplicated uniqueid record to display.

And I haven’t touched on what to do when the duplicate items donnn’t contain the user’s favourite store yet :frowning:

But this is an issue you have to address no matter the technical solution.

not sure I understand why…

whether you were doing this in Excel, SQL, bubble, etc how would the platform know which duplicated record to display?

count of unique uniqueids=1,
vendor=user’s favourite store,
union (shoes left join defaultviews) where priority =(max priority in group)

or something like that. I am a SAS programmer, more than a SQL programmer