Airtable Cobuilder is here! Learn more about our new no-code app creation feature, powered by AI on the Airtable Academy

Count Unique Values in Rollup

Jump to Solution
9137 13
Showing results for 
Search instead for 
Did you mean: 
7 - App Architect
7 - App Architect

I’ve had to do this quite a few times… my old solution was:

  1. Rollup with ARRAYUNIQUE(values)
  2. Remove any trailing ','s in another column
  3. Count the remaining commas, +1

Now I do it all inside the rollup with the following snippet:



    FIND(",", ARRAYJOIN(ARRAYUNIQUE(values), ",")&"") = 1, 
    SUBSTITUTE(ARRAYJOIN(ARRAYUNIQUE(values), ",")&"", ",", "", 1), 
        FIND(",", ARRAYJOIN(ARRAYUNIQUE(values), ",")&"", LEN(ARRAYJOIN(ARRAYUNIQUE(values), ",")&"") - 1), 
This file has been truncated. show original

And yes - I’m keeping it as a Gist on GitHub for easy access. I’ll be adding more of these gems as I go.

1 Solution

Accepted Solutions
18 - Pluto
18 - Pluto

If there might be empty values, you could use
instead of

The differences between COUNTA() and COUNTALL() are documented in the formula field reference. COUNTALL() counts all values, including blanks. COUNTA() does not count blanks.

See Solution in Thread

13 Replies 13
6 - Interface Innovator
6 - Interface Innovator

That’s awesome. How would you address the issue if some of the values being rolled up included a comma. In my example, a corporate name that included a comma (ie ABC Widgets, Inc.)?

Oooph! Very interesting. I suppose you’d have to work from the fact that Airtable will always use a ‘,’ separator…

Perhaps you could make a column called Safe Corporate Name that replaces ','s found in your Corporate Names and replaces them with another character using SUBSTITUTE() – and then you can use this Rollup formula on that field instead.

Hope that helps.

4 - Data Explorer
4 - Data Explorer

Hey thanks for this! It’s exactly what I needed.

6 - Interface Innovator
6 - Interface Innovator

Just what we needed, thank you thank you

Or you could use …

7 - App Architect
7 - App Architect

@kuovonne I was about to throw all of my papers in the air from my desk and shout from the rooftops “She’s solved it!”

However, I’m not sure these two are doing the same thing, but I don’t know why that is. Let me demonstrate:


Arrayunique just uses ARRAYUNIQUE(values) to list them.

Any thoughts? Is there a tweak to yours that would work?

That does look strange.

Are you rolling up the same target field from the other table?

Do you have any blanks in the field being rolled up? (I doubt it, or there would be two commas in a row.)

What is the field type of the field being rolled up?

5 - Automation Enthusiast
5 - Automation Enthusiast

Slightly more concise way of counting array items.

Where [Unique Editors] is a compacted, unique, joined array.

Assumes no commas in array values

  LEN({Unique Editors}) > 0, 
  LEN(REGEX_REPLACE({Unique Editors},"[^,]",""))+1,
7 - App Architect
7 - App Architect

Just returning to this – @kuovonne is 100% correct, the only addition is to add a condition in the rollup that the thing you’re looking for unique values of is not empty.

I am going to edit my post to make sure no one wastes their time on my awful, awful alternative :grinning_face_with_big_eyes: