Skip to main content

Remove duplicates in look up field


Show first post

112 replies

Forum|alt.badge.img+6

Keeping the chain going, would love to have this! Currently using the workaround given, but having just a toggle option would make a bunch of things more streamlined.


Forum|alt.badge.img+11
  • Participating Frequently
  • 11 replies
  • May 8, 2023

Just sharing this improved automation workaround I found (through help from Airtable) that doesn't require checking a box--though a lookup field that only looked up unique values would still be best!


Forum|alt.badge.img+1
  • New Participant
  • 1 reply
  • June 7, 2023

Accidentally found a quick semi-fix for this if you just need to get it done. Going back to the Chicken Club Sandwich Example on page 1:
- Create a new new linked column (linking directly to "type")
- Copy the data from the "type" lookup column/cell
- Paste into your new directly linked "Type" column/cell
When it pastes into the new column, the dupes are removed!

Not ideal, but it might work for some use cases!


Forum|alt.badge.img+1

Both depressing and heartening to see so many years of people with the same issue.

I've tried the workarounds but the duplicate value I'm having is duplicates of the same user being listed in a field and the currently presented workarounds don't seem to work for that.


Forum|alt.badge.img+7
  • Participating Frequently
  • 16 replies
  • August 27, 2023

Just keeping an eye on this as well. I'm unable to get unique names for a template I'm creating. Been searching, but nothing working so far. My case involves two source tables (Tables A & B) from a base (Base 1) multi-syncing to one target table (Table C) in another base (Base 2). In Base 2, I have Table D linking to Table C, and this is where I run into the issue where linked assignees from the sources (A & B) cannot be shown as unique values only, no matter what kind of rollup, lookup, formula combos I try.


Forum|alt.badge.img+8
  • Participating Frequently
  • 14 replies
  • November 6, 2023
Adam_Minich wrote:

Hello community!

Adam from the Airtable customer support team here. I had an Airtable user reach out with a link to this community post. While I can’t speak to a specific timeframe for when this feature might be available I have a workaround that may help.

I used the Recipe, Ingredients, and food type example from earlier in the thread. Also, you will need to have some comfort with our Automations feature in order to use this method:

Hope this helps and know that our team is very thankful to our community!

P.S. It may make more sense to set up the automation trigger to be “When a record is updated” and have it just watch the “Array Unique” rollup field.


Hi, community 👋

I came up with a solution using the Scripting automation that

  • Does not require extra columns
  • Works with records AND attachments
  • Allows you to sort them, filter them, or do any other operation on them to the extent of Javascript's capabilities
  • Was battle tested on thousands and thousands of records

 

Attachments

Here is an example summarizing Attachments from all of a Contact's Emails :

  • Contact table with fields
    • Attachments from Emails
    • Emails
  • Email table with field
    • Attachments

 

const { contact_id } = input.config() const ContactTable = base.getTable('tbl8dODvN066m2wIc'/*Contact*/) const EmailTable = base.getTable('tbl6LDjmzV2Rc8jKq'/*Email*/) const Contact = await ContactTable.selectRecordAsync(contact_id) const Emails = Contact?.getCellValue('fld03ip9p2K8XARnL'/*Emails*/) || [] const EmailIds = Emails.map(i => i.id) const Emails = await selectRecordsAsyncInBatches(EmailTable, { recordIds: EmailIds, fields: [ 'fldxrp1KuecaoypBc'/*Attachments*/, ], sorts: [] }) const attachments = [] for (const Email of Emails || []) { attachments.push(Email?.getCellValue('fldxrp1KuecaoypBc'/*Attachments*/)) } const attachmentsUnique = uniqueAttachments(attachments.flat().filter(i => i?.id)) output.set('Attachments from Emails', attachmentsUnique) function uniqueAttachments(attachments) { return attachments.filter( (record, index, array) => array.findIndex( ({ filename, size }) => ( filename === record.filename && size === record.size )) === index); }

 

I am basing myself off of filename + size to determine if a file is unique. It is not as good as using a hash, but has been working out pretty well for us for the past year or so.

 

Records

If, instead of looking up Attachments, you want to lookup records, the code is exactly the same with just replacing the function uniqueAttachments with uniqueRecords :

 

function uniqueRecords(records) { return records.filter( (record, index, array) => array.findIndex( ({ id }) => id === record.id ) === index); }

 

Enjoy ❤️


Forum|alt.badge.img+11
  • Participating Frequently
  • 11 replies
  • December 20, 2023
Thomas_de_Beauc wrote:

Hi, community 👋

I came up with a solution using the Scripting automation that

  • Does not require extra columns
  • Works with records AND attachments
  • Allows you to sort them, filter them, or do any other operation on them to the extent of Javascript's capabilities
  • Was battle tested on thousands and thousands of records

 

Attachments

Here is an example summarizing Attachments from all of a Contact's Emails :

  • Contact table with fields
    • Attachments from Emails
    • Emails
  • Email table with field
    • Attachments

 

const { contact_id } = input.config() const ContactTable = base.getTable('tbl8dODvN066m2wIc'/*Contact*/) const EmailTable = base.getTable('tbl6LDjmzV2Rc8jKq'/*Email*/) const Contact = await ContactTable.selectRecordAsync(contact_id) const Emails = Contact?.getCellValue('fld03ip9p2K8XARnL'/*Emails*/) || [] const EmailIds = Emails.map(i => i.id) const Emails = await selectRecordsAsyncInBatches(EmailTable, { recordIds: EmailIds, fields: [ 'fldxrp1KuecaoypBc'/*Attachments*/, ], sorts: [] }) const attachments = [] for (const Email of Emails || []) { attachments.push(Email?.getCellValue('fldxrp1KuecaoypBc'/*Attachments*/)) } const attachmentsUnique = uniqueAttachments(attachments.flat().filter(i => i?.id)) output.set('Attachments from Emails', attachmentsUnique) function uniqueAttachments(attachments) { return attachments.filter( (record, index, array) => array.findIndex( ({ filename, size }) => ( filename === record.filename && size === record.size )) === index); }

 

I am basing myself off of filename + size to determine if a file is unique. It is not as good as using a hash, but has been working out pretty well for us for the past year or so.

 

Records

If, instead of looking up Attachments, you want to lookup records, the code is exactly the same with just replacing the function uniqueAttachments with uniqueRecords :

 

function uniqueRecords(records) { return records.filter( (record, index, array) => array.findIndex( ({ id }) => id === record.id ) === index); }

 

Enjoy ❤️


Thanks for sharing, @Thomas_de_Beauc!

I'm not familiar with scripting and only have very minimal JS experience so not sure I want to try to take this on until I know it might do what I want. In my case I have 3 tables: Participants, Facts, Insights.

I enter facts in the Facts table and tie them to both Participants and Insights in respective "link to another table" fields. What I want is to have is a lookup field on the Insights table that looks up Participants from the Facts table, but that only brings in unique Participants.

It doesn't sound like Attachments would be a 3rd table in your case. So I guess I'm wondering: would your script still work to pull in unique records that are clickable (just as normal lookup fields pull in clickable records if they're pointing at a "link to record" field)? Thanks for considering!


Forum|alt.badge.img+8
  • Participating Frequently
  • 14 replies
  • January 17, 2024
Natalie_Zdan wrote:

Thanks for sharing, @Thomas_de_Beauc!

I'm not familiar with scripting and only have very minimal JS experience so not sure I want to try to take this on until I know it might do what I want. In my case I have 3 tables: Participants, Facts, Insights.

I enter facts in the Facts table and tie them to both Participants and Insights in respective "link to another table" fields. What I want is to have is a lookup field on the Insights table that looks up Participants from the Facts table, but that only brings in unique Participants.

It doesn't sound like Attachments would be a 3rd table in your case. So I guess I'm wondering: would your script still work to pull in unique records that are clickable (just as normal lookup fields pull in clickable records if they're pointing at a "link to record" field)? Thanks for considering!


Hi Natalie,

Sorry for the late reply, life has been busy.

In the context of my script, Attachments are directly interchangeable with Linked records, they are treated the same. The only difference is to replace the uniqueAttachments with the uniqueRecords function, besides that you could just write records instead of attachments in every variable name and it would work just the same.

Here it is: 

const { contact_id } = input.config() const ContactTable = base.getTable('tbl8dODvN066m2wIc'/*Contact*/) const EmailTable = base.getTable('tbl6LDjmzV2Rc8jKq'/*Email*/) const Contact = await ContactTable.selectRecordAsync(contact_id) const Emails = Contact?.getCellValue('fld03ip9p2K8XARnL'/*Emails*/) || [] const EmailIds = Emails.map(i => i.id) const Emails = await selectRecordsAsyncInBatches(EmailTable, { recordIds: EmailIds, fields: [ 'fldxrp1KuecaoypBc'/*Attachments*/, ], sorts: [] }) const records = [] for (const Email of Emails || []) { records.push(Email?.getCellValue('fldxrp1KuecaoypBc'/*Linked records*/)) } const recordsUnique = uniqueRecords(records.flat().filter(i => i?.id)) output.set('Records from Emails', recordsUnique) function uniqueRecords(records) { return records.filter( (record, index, array) => array.findIndex( ({ id }) => id === record.id ) === index); }

 In this example, you could imagine that every Email is linked to a sale from the table Sale, so here for a given Contact it would go through every Email and summarize all the Sales that this Contact was involved in.

Hope this is clearer


Forum|alt.badge.img+8
  • Known Participant
  • 11 replies
  • January 22, 2024

I find it crazy this feature has been requested for years but still isn't available? 

Airtable please make it an option to have lookup fields only displaying unique values! I don't want to use a rollup for the above reasons that I want it to be linked records. 


Venger
Forum|alt.badge.img+1
  • New Participant
  • 2 replies
  • March 11, 2024

Forum|alt.badge.img+2
  • New Participant
  • 1 reply
  • September 27, 2024

Just another person +1ing the need for this feature, years and years later.

I get that there's a work around and I'm sure with enough time and focus I could figure out how to do it, but as someone who is constantly bringing organizations I work with to airtable, it would be great to have a way to do this clearly useful function without having to have a fundamental understanding of coding/programming to make it happen. 


Forum|alt.badge.img+7
  • Participating Frequently
  • 16 replies
  • September 27, 2024

Sharing the simplest way I found to do this without the need for scripting or automations. Copying my email to Airtable support:

This was resolved to my expectations by taking the following steps:

  1. Create the rollup field in Table A on the Linked Table B’s field I want to rollup, in this case a multiselect field.
  2. Take that same rollup field that was just created, and change it to a Lookup field.
    1. (The lookup field will now display as text, instead of the colorful word bubbles you usually see from multi-select fields)
  3. Create a formula field in the Table A, and ARRAYUNIQUE the “formerly a rollup now a lookup field” field.
  4. Ta-da

Is Airtable aware of this strange behavior? If so, can we make it simpler and more intuitive to get unique values out of rollup or lookup fields?


Reply