Forum Academy Marketplace Showcase Pricing Features

Unique element in a repeating group

Hi,

I am trying to use the “unique element” functionality:

However, when I preview, I still have duplicates:

Here is an extract of my database:
Etablissement, Niveau, Spécialisation, Responsable
HEC,M1,Finance,M. Moutro
HEC,M2,Finance,Mme Duperrel
Polytechnique,L1,Cursus général,M. Franchier
Polytechnique,L2,Cursus général,M. Franchier
etc.

Am I wrong in the syntax of :unique element?

In your Formation table, you’ve got several “Paris-Dauphine” as a name, right ? Because the unique element applies on one item (ie one row in your database), not on the name which is a Formation’s attribute.
Can you try to change the Type of content = text and Data source = Search for Formations’s name:unique elements ? I guess it may work.

I have the same problem and seems like you cannot make the CONTENT to text and then DATA SOURCE to the Table that you are trying to view. Because then content FIELDs in the repeating group give you an error (red text).

So what is the solution for a simple repeating group to show unique values?

Thanks

Data source would need to be text to match the content type, so keep drilling down to the text field in your Thing (table).

For example type = text, source = search for user’s first name: unique elements. This would give you a list of unique first names.


Gaby | Coaching Bubble

1 Like

@romanmg

Gaby, Ok that works (for me) if the only thing in the repeating group is just that text element. For example COMPANY NAME but what if I need the unique COMPANY name and its PHONE NUMBER as elements each row.

I could not find a way to add the phone number next to the company name?

thanks

So what is the unique piece in your list? You’ll need to restructure the RG if the list is going to be a list of things (like companies) instead of text.

The table contains jobs names done by company name and their phone number for the current user. So a company can do many jobs for the current user. I am trying show/ extract a list of just companies and thier phone numbers that have done work for the for the user as a convenience. It works but since a company can do several jobs for a user, then it appears many times in the repeating group.Thats the reason i need unique company names but i also want to show the phone number in the repeating group.

I think you should structure your database something like this:

Company

  • Phone (text)
  • Name (text)
  • Jobs (list of jobs)

Job

  • Job name (text)
  • Company (company)

User

  • Jobs (list of jobs)

That way the repeating group can be type = company, source = current user’s job’s company : unique elements

The text elements in the cell can then be “current cell’s company name” and “current cell’s company phone”


Gaby | Coaching Bubble

1 Like

Gaby,
I see what you are doing. Being new to Bubble I did not take advantage of the ‘Bubble’s way’, instead I was adding via, workflow, the field-content to each new records as I created them, thus associating jobs with companies and users.

Lesson learned.

Thanks

The more time you spend with your app, the more you’ll know better than anyone how it should be structured. I’m glad this could help you get started, but don’t feel like you need to be tied to it. As long as you’re understanding the different ways to cross reference data, saving, etc., you’ll find what’s best.

Keep asking questions when you have them! So many of us here to help :slight_smile:

1 Like

@romanmg

Sry to revive this topic, but I’m having the same problem. I was able to do a list of unique elements in a repeating group, but when I tried to show the amount of repetitions each unique value had, I got stuck. In a simple SQL query would be something like: “select distinct(client), count(client) from database group by 1”, showing a column with the uniques values and other with the # of repetitions each one had.

What worked for the list is…
type of content = number
data source = search for table’s client unique elements
text element = current cells’s number

But as the data source was already the list of unique elements, I guess that’s the reason I cant perform the count function.

So I followed the instructions and changed the things for lists, so I could use…
type of content = table
data source = search for table
text element = current cell’s table’s client unique element

Hoping that I would have the same unique list. However, it show a list with repeated values! So i started going in circles.

What am I doing wrong? Any color?

THANKS!

Hey @felipe, could you share a link to your app? I can probably be of more help if I see what you’re talking about in context :slight_smile:

Sure !!! this is kind of the “backoffice” of the app.
Is it possible to share the editor mode? I didnt find it.

I can access it, thank you. So, can you describe the data a little? It seems like, if you just add :count to the 2nd dynamic text, that counts up how many items are in the list for each cell’s “vizita’s client”… but I’m not sure if this is your goal.

hum… no… let me explain a little more. It is a loyalty app for merchants. The client types his code in page tablet_app, and he accumulates points (that I call vizits) that can be redeemed at consumer_page).

The merchant has its admin page, where he can created rewards (recompensas), see the client list (clientes) and see all redemptions (resgates).

For the client list, what I am trying to do is to build a list of unique values for the clients. For example, client1 visited the store 5 times and client2 visited twice. Im trying to do a list like this…

client1: 5 visitis
client2: 2 visitis

I was able to build the list of unique clients, but not the count. I trying a different angle and I was getting the list of clients (not unique).

Trying to include the count element in the formula, is giving me (i) the total count for all visits and not for each client or (ii) always 1, that is current cells count.

Could I explain it a little better? Sry, not my mother tongue! :blush:

Again, thank you so much for your time.

First, if you speak Spanish, go ahead and explain in Spanish, I can read it fluently, but I’ll respond in English if that’s ok.

Ok, so I understand the list you want to build, but your data structure is confusing me a bit. Let me make sure I’m understanding…

Consumidor is the client? And “CPF” is their ID number?

Vizita is the type that doesn’t make sense. Do you want this to be a record of a list of clients that visit for each merchant? Meaning, 1 Vizita will contain the list of clients that visited 1 Merchant. Another Vizita record will contain a separate list of clients that visited another Merchant? If that’s what you want, you need to change the structure a bit so that the Merchant field is not a list. Also, I would change the Client field from a list of numbers to a list of Consumidores. I’m assuming this list of numbers is the CPF number for each Consumidor/client. Or am I super wrong?

Let me know about that, and then I’ll see what we need to do. I just think your structure is a little bit off in general based on the app’s goals.

No, you understand it correctly, just a few changes… the data type consumidores Im not using (just deleted it). CPF is a code everyone in Brazil has, so it is very common to use it as a primary key.

The misunderstanding if just regarding the table called vizita. It records each individual visit from a client to a store, so it is an event list. A client can visit many stores, a store can have many clients and visits. Thats why I created the data type “vizita”, so that I can register the event “client X visited store Y”.

Got it?

So wouldn’t you want the fields within the Vizita type to be a singular client and a singular store? Because the type represents 1 record - that is, 1 visit. Multiple visits from 1 client to 5 different stores would result in 5 Vizita records. From that structure, you can identify all the clients and visits a store had.

Vizita

  • Client (number)
  • Merchant (text)

Vizita Record 1

  • Client 1
  • Merchant 1

Vizita Record 2

  • Client 1
  • Merchant 2

Vizita Record 3

  • Client 2
  • Merchant 1

To search for all clients of Merchant 1: Search for Vizita’s Client’s : unique elements (with constraint, Merchant = Mercant 1)… This will result in Clients 1 and 2.

To search for the number of visits each client had within the same RG using the search described above, that dynamic expression would be Search for Vizitas :count (with constraint, Merchant = Merchant 1, Client = current cell’s client). This will result in a count of 1 for both clients.

I think it should be noted that a field that is a list will not store duplicates. If you add 1, 5, 6, 5, 5, 5 to a list field, your list value will actually just be 1, 5, 6. So if I’m following correctly, you need to make this field a singular value anyway.

1 Like

Thank you! That worked! You are saving me… :slight_smile: tks tks tks

1 Like

Sorry to re-open this thread again but does any have suggestions on how to use :unique element in a repeating group when that repeating group contains texts and images?

The issue I am having is :unique element seems to require type text but if I set it to type text my images don’t display. From all the other threads I have read similar to this one it is likely a database issue but one I cant solve.

Any help is much appreciated!
Thanks :slight_smile:

1 Like