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
 63K Get Help
 380 Global Discussions
 212 Industry Talk
 442 Announcements
 4.6K Ideas & Feature Requests
 140 Brandfolder
 129 Just for fun
 130 Community Job Board
 449 Show & Tell
 30 Member Spotlight
 1 SmartStories
 305 Events
 34 Webinars
 7.3K Forum Archives
Check out the Formula Handbook template!