I’ve had to do this quite a few times… my old solution was:
Rollup with ARRAYUNIQUE(values)
Remove any trailing ','s in another column
Count the remaining commas, +1
Now I do it all inside the rollup with the following snippet:
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.
Best answer by kuovonne
If there might be empty values, you could use COUNTA(ARRAYUNIQUE(values))
instead of COUNTALL(ARRAYUNIQUE(values))
The differences between COUNTA() and COUNTALL() are documented in the formula field reference. COUNTALL() counts all values, including blanks. COUNTA() does not count blanks.
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.)?
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.
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:
If there might be empty values, you could use COUNTA(ARRAYUNIQUE(values))
instead of COUNTALL(ARRAYUNIQUE(values))
The differences between COUNTA() and COUNTALL() are documented in the formula field reference. COUNTALL() counts all values, including blanks. COUNTA() does not count blanks.
Doesn’t work:
COUNTALL(ARRAYUNIQUE(values))
for
Rollup fields aren’t an option for other rollups, so in my case, trying to count the unique values in the rollup field won’t work. I have the above in a formula field and it only returns a 1.
This is the solution that I am looking for but it isn't returning the right number, I think because the values I'm trying to count have a comma in them. Would this be why and would you suggest how to fix? I am not a coder so modifying your code is difficult for me.