How to get unique information from an column by using formulas

I have a simple grid view data like that:

and I want to filter my data by company’s uniqueness and get an array which includes list of companies by unique like ['Google', 'Facebook', 'Apple'] read Formula Field Reference but couldn’t find. I can fetch entire data and make filtering on client side but instead of getting entire data, I want to pull only array of companies. By code below so far. Thank you

    const RES = await db('users').select({
      view: 'Grid view',
      filterByFormula: 'some filter should be happen at there',
    console.log(RES) // should return ['Google', 'Facebook', 'Apple']

Hey you’d want to create an array of the Company, and potentially use ARRAYUNIQUE([item1, item2, item3])

Hi @kaan_g - if RES is returning an array of users (which I guess it is), then you could do something like:

let unique = [ Set( => user['Company']))];

I haven’t tested this out, but the following works nicely in Airtable scripts, so hopefully you can modify for your code:

let peopleTbl = base.getTable('People');
let query = await peopleTbl.selectRecordsAsync();

let unique = [ Set( => person.getCellValue('Company')))];

based on this table:

This is creating a new Set, then “spreading” the values of the Set object to an array.

1 Like