Skip to main content

How to Use the Unique Elements Operator

Sofia Maconi avatar
Written by Sofia Maconi
Updated over a month ago

Transcript

In this Quick Tip, we're going to learn how to use the unique elements operator to remove duplicates from a list of text.

From time to time, you may have duplicates in your list that you source or generate — for example, like when users submit their own tags. While it's fine to submit tags of the same name, you wouldn't want to offer duplicated tag names for them to choose from.

Here, we have a list displaying every tag in our tag database by searching for tags. And here, we have a multi-select dropdown that is searching for these tags' names.

But note: our type of choices is not Tag — we're looking for text. Since each tag we add to the database is its own unique thing, we have to search this way and get a list of text back, not a list of tags.

At the end of our search, we add the unique elements operator. This operator removes duplication from a list of text.

So let's test this out.

We add a new tag named “test.” Then we add another tag named “test.”


We now have two things with the name of “test,” but only one of them will show in our multi-select dropdown — because we remove duplication thanks to the unique elements operator. Note that this does not remove the thing from the database.

When using unique elements, case sensitivity matters. If multiple tags share the same name, but one is spelled with a capital letter, it won't be considered for removal.

That's it for this Quick Tip! For more, be sure to check out bubble.io/academy.

Did this answer your question?