Formula to count distinct values in a column that contain a certain text string
I am looking for a way to count distinct values in a column, but only if the values contain a certain text string. For example, in my Fruit column, I'd like to count the unique values that contain "Large." In this case, the number should be 3.
Fruit
Apple - Small
Apple - Medium
Apple - Large
Orange - Small
Orange - Medium
Orange - Medium
Orange - Large
Pear - Small
Pear - Medium
Pear - Large
Pear - Large
I've tried =COUNT(DISTINCT(Fruit:Fruit)), but that would give me all the distinct values, or 9.
I've tried =COUNTIF(Fruit:Fruit, CONTAINS("Large", @cell)), but that gives me all the instances of "Large," or 4.
Any ideas?
Thanks!
Best Answer
-
try adding in a COLLECT:
=COUNT(DISTINCT(COLLECT(Fruit:Fruit, Fruit:Fruit, CONTAINS("Large", @cell))))
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
Answers
-
try adding in a COLLECT:
=COUNT(DISTINCT(COLLECT(Fruit:Fruit, Fruit:Fruit, CONTAINS("Large", @cell))))
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64K Get Help
- 412 Global Discussions
- 220 Industry Talk
- 459 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 138 Just for fun
- 57 Community Job Board
- 459 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 298 Events
- 37 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!