Create script that finds duplicates within a cell

Hi there!

After searching around for a while, I have not been able to find a script with the function of finding duplicates within one cell.

I have found workarounds with Airtable automations, the only task holding me back now is the script.

In this case, I want to be able to find and copy duplicated values from a cell (formula cell) into another cell (link to… cell).

Image 1: Here you can see the structure of the table. Column 4 (Concatenated (FORMULA)) combines the values from column 2 and 3 (Outcome 1 and 2) into one cell.

I wish to identify the duplicates within cell “concatenated” and return the duplicated variables to the column cell “Duplicate” (Sample 1) (Notice that the cell “Duplicate” is formatted as “link to…” cell).

IMPORTANT: IF there is more than 1 duplicate, I want to return all duplicates into cell “Duplicate”. (Sample 2) I wish to make this process automatic.

Outcome 1 and 2 are results we receive automatically from an online form. Airtable automatically concatenates outcome 1 and 2. However, I wish to automate the duplicate finder. For this, I would need a Java expert to create a script for Airtable.

To do:

  1. Find duplicates within a cell and return duplicates in another cell
    • Copy a value from a “formula” cell and copy it to a “link to…” cell automatically when updated.
    • If multiple duplicates, show all.

Thank you!

Is there a practical limit on the number of Outcome values? Also, if you want those tags automated, expect some fiddling with the silly automation UI. I’d suggest using the “when a record enters view!” trigger to start the tagging attempt because that one is easy enough to reset.

As for the rest of these requirements, it sounds like you pretty much know what to do, no? Post any code that’s giving you trouble here but if the requirements don’t go far beyond what you’ve described, an imperative approach shouldn’t be too difficult to accomplish. I’d also consider avoiding the Scripting app entirely in your place as a few inelegant formulas can get you what you need, as well.

Thank you for your answer @Dominik_Bosnjak !

Unfortunately, I haven’t been able to find any type of code that even gets close, hence i’m not able to post any code thats giving me trouble.

I like the idea of fixing this with formulas. What type of formula/s were you thinking of? I would also like to avoid the scripting app to keep things simple.

Any idea is welcomed!

Are you able to post a mockup version of that table? I wish I could write some kind of a formula-based recursion off the top of my head but the way I usually solve these things is to poke at the problem, especially at 1am. :sweat_smile: