Count the number of distinct subsets of a string that match a criteria
I need to create a formula to count the number of distinct subsets of a string that match a criteria.
For example.
I have a sheet with a column foo. the foo column contains the following
A-Z
A-Y
A-Z
A-X
A-Y
B-A
B-B
C-D
C-D
I need a formula that looks at this column and returns the number of distinct A(s) which would be three in my example. One for A-Z, one for A-Y and one for A-X.
Thanks in advance,
Nick
Best Answer
-
Hi @Nick DeMarco ,
Try this:
=COUNT(DISTINCT(COLLECT(FOO:FOO, FOO:FOO, FIND("A", @cell) = 1)))
It should work for your example. But, it is hard coded for your example and the logic may not work for your real use case.
Help at all?
Mark
I'm grateful for your "Vote Up" or "Insightful". Thank you for contributing to the Community.
Answers
-
Hi @Nick DeMarco ,
Try this:
=COUNT(DISTINCT(COLLECT(FOO:FOO, FOO:FOO, FIND("A", @cell) = 1)))
It should work for your example. But, it is hard coded for your example and the logic may not work for your real use case.
Help at all?
Mark
I'm grateful for your "Vote Up" or "Insightful". Thank you for contributing to the Community.
-
Mark,
Thank you! This was exactly what I needed!
Regards,
Nick
-
Happy to help. Thanks for using the Communuty.
Mark
I'm grateful for your "Vote Up" or "Insightful". Thank you for contributing to the Community.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65.2K Get Help
- 445 Global Discussions
- 143 Industry Talk
- 476 Announcements
- 5K Ideas & Feature Requests
- 84 Brandfolder
- 150 Just for fun
- 71 Community Job Board
- 488 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 301 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!