How to get unique information from an column by using formulas

Topic Labels: API
4152 2
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

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']
2 Replies 2

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')))];

Screenshot 2020-05-18 at 13.09.08

based on this table:

Screenshot 2020-05-18 at 13.10.17

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