COUNTIFS/CONTAINS FUNCTION
Hi All,
I need help with a formula to Count every instance a name appears in a multi-select row of a column based on criteria from another column first. At present this is my first formula:
=COUNTIFS({CORP ADMIN TEAM TASKS Range 1}, "In Progress", {CORP ADMIN TEAM TASKS Range 2}, "Jane Doe")
However, it is only counting the name once it is the only option in the cell. So if Jane Doe appears alongside John Doe and Jack Doe in the multi-select cell, it will not count the name.
I tried this formula below, but it returns UNPARSEABLE:
=条件统计(包含(“进步”,[集团管理TEAM TASKS Range 1]:[CORP ADMIN TEAM TASKS Range 1]), "TRUE", "FALSE"), CONTAINS ("Jane Doe", [CORP ADMIN TEAM TASKS Range 2]:[CORP ADMIN TEAM TASKS Range 2]), "TRUE", "FALSE").
Answers
-
Paul Newcome ✭✭✭✭✭✭
You are actually closer to being on the right track with your first. Give this a try...
=COUNTIFS({CORP ADMIN TEAM TASKS Range 1}, "In Progress", {CORP ADMIN TEAM TASKS Range 2},CONTAINS("Jane Doe",@cell))
-
RySols ✭
Thanks Paul. Appreciate the assistance.This works perfectly if the function is being done on the same sheet. See below:
=COUNTIFS(Status1:Status10, "In Progress", [Assigned To]1:[Assigned To]10, CONTAINS("Jane Doe",@cell))
However, when referencing an external sheet, it doesn't return the correct values as in the example you provided.
Any suggestions? .... Once again, appreciate the help.
Ryan
-
Paul Newcome ✭✭✭✭✭✭
What do you mean by "it doesn't provide the correct values"?
If it is working correctly on the same sheet as the data, then (as long as the ranges are the same as when you put it on the same sheet and cross-sheet references are built correctly) it should provide the same results on a different sheet.
Are you able to provide some screenshots showing the differences?
In your example above you referenced rows 1 - 10 when the formula is on the same sheet as the data... Did you select those same rows when setting up your cross sheet reference?
Try creating a temporary filter on the data sheet so that it reflects the same ranges and criteria as the formula you are trying to build. That will help you verify what is being pulled by the formula.
-
RySols ✭
Hi Paul,
I believe I may have figured out the issue.The cross references work fine providing that the data in the multi-select column are names that you physically entered in the column properties. But when the column properties is a contact list, the formula will not work. I've reached out to smartsheets support team to see if they can offer any insight into this problem. I'll be sure to post an update once they get back to me. Thanks again.
Ryan
-
Paul Newcome ✭✭✭✭✭✭
The Contact type column would be the issue. CONTAINS doesn't care too much for that column type. Try changing the CONTAINS to a FIND.
CONTAINS("Jane Doe",@cell)
to
FIND("Jane Doe",@cell)> 1
.
One thing to note with this change: FIND is case sensitive whereas CONTAINS is not, so you will want to be sure to keep that in mind.
If you are using "jane doe" in the FIND function, it will not find Jane Doe. Likewise using "Jane Doe" in the FIND function, it will not find jane Doe, Jane doe, Jane, Doe, or anything else.
It can search in a text string of multiple names, but the case sensitivity is something to keep in mind.
-
RySols ✭
Hi Paul,
Just an update. That solution was almost spot on, however the correct one is below:
=COUNTIFS({CORP ADMIN TEAM TASKS Range 1}, "In Progress", {CORP ADMIN TEAM TASKS Range 2}, FIND("Jane Doe", @cell) > 0)
Instead of using FIND("Jane Doe", @cell) > 1), it should be FIND("Jane Doe", @cell) > 0)
The formula is working perfectly with this solution and capturing the correct values inclusive of being able to work in the Contacts Properties column.
-
Paul Newcome ✭✭✭✭✭✭
You are absolutely correct, and that was my mistake. I use the FIND function in this very way quite frequently, so I think maybe my fingers were moving faster than my brain. My apologies. Glad you got it figured out though!!
-
Try
=COUNTIFS({CORP ADMIN TASKS Range 1}, "In Progress", {CORP ADMIN TASKS Range 2}, HAS(@cell, "Jane Doe")
-
Paul Newcome ✭✭✭✭✭✭
The problem with the HAS function is that it will only count if that is the only name in the cell. Since there is the possibility of multiple names, we need to be able to check the entire string for a match within it as opposed to an exact match on the string.
-
I have a similar situation, but would need to count each instance of "Doe". If the cell contained Jon Doe, Jane Doe and Jen Doe I would like the output return 3. I attempted the solution given, but it only returns 1. Thank you.
-
Paul Newcome ✭✭✭✭✭✭
For this you would need to parse out the names into their own cells and count them that way.
-
kyle.macleod ✭✭
I'm having the exact same problem, but using CONTAINS isn't working for me. Instead of looking for contains "text" search, I'm trying to look for contains {cell reference contents).
The formula below works fine as long as the searched cell only contains one thing. If there are multiple options, it doesn't count at all.
Whenever I try the syntax above and use the CONTAINS I get an error.
Note, the first part of that formula I put there to eliminate the response of "0", as that messes up with my dashboard graphs. I think I'm just messing up my () somewhere... although also I'm not exactly sure how @cell works.
Any ideas? I'm tired of trying and reaching out for help from you experts. Thank you in advance.
-
Paul Newcome ✭✭✭✭✭✭
@kyle.macleodYou should be able to use the syntax of
=COUNTIFS({Range},CONTAINS([Primary Column]@row, @cell))
-
kyle.macleod ✭✭
Paul, you rock. thank you.
For whatever reason, when I copy/paste it didn't work. But when I slowly build each argument one at a time, it works. I probably had an extra (or missing) syntax somewhere.
-
Paul Newcome ✭✭✭✭✭✭
Help Article Resources
Categories
Check out theFormula Handbook template!
Instead of applying the formula to \"Multiselect Text String\" row, did you tried with \"Multiselect Values\" row?<\/p>
=IF(HAS([Multiselect Values]@row, [Component ID]@row), \"MATCH\", \"NO MATCH\")<\/p>
Thank you,<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]},{"discussionID":109493,"type":"question","name":"I am having trouble using \"And\", \"OR\" & \"Countif(s)\" to build a formula.","excerpt":"Hello, I am attempting to come up with a sheet summary formula that counts cells if they meet at least one of 3 different statuses in the same column, AND also meet one of 5 different statuses in a separate column. So using the screenshot I've provided as an example (although it doesn't have 5 different statuses in the…","snippet":"Hello, I am attempting to come up with a sheet summary formula that counts cells if they meet at least one of 3 different statuses in the same column, AND also meet one of 5…","categoryID":322,"dateInserted":"2023-08-25T20:03:21+00:00","dateUpdated":null,"dateLastComment":"2023-08-26T00:34:49+00:00","insertUserID":165710,"insertUser":{"userID":165710,"name":"SmarsheetNewb","url":"https:\/\/community.smartsheet.com\/profile\/SmarsheetNewb","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-26T00:33:27+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":161714,"lastUser":{"userID":161714,"name":"Carson Penticuff","url":"https:\/\/community.smartsheet.com\/profile\/Carson%20Penticuff","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/B0Q390EZX8XK\/nBGT0U1689CN6.jpg","dateLastActive":"2023-08-27T02:16:35+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":24,"score":null,"hot":3386005690,"url":"https:\/\/community.smartsheet.com\/discussion\/109493\/i-am-having-trouble-using-and-or-countif-s-to-build-a-formula","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109493\/i-am-having-trouble-using-and-or-countif-s-to-build-a-formula","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":109493,"commentID":392692,"name":"Re: I am having trouble using \"And\", \"OR\" & \"Countif(s)\" to build a formula.","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392692#Comment_392692","dateInserted":"2023-08-26T00:34:49+00:00","insertUserID":161714,"insertUser":{"userID":161714,"name":"Carson Penticuff","url":"https:\/\/community.smartsheet.com\/profile\/Carson%20Penticuff","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/B0Q390EZX8XK\/nBGT0U1689CN6.jpg","dateLastActive":"2023-08-27T02:16:35+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-08-26T00:33:25+00:00","dateAnswered":"2023-08-25T20:44:12+00:00","acceptedAnswers":[{"commentID":392662,"body":"
Try this:<\/p>
=COUNTIFS([Item Number]:[Item Number], OR(@cell = \"C001\", @cell = \"COO2\", @cell = \"COO3\", @cell = \"COO4\"), [Status]:[Status], OR(@cell = \"Green\", @cell = \"Yellow\", @cell = \"Red\"))<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":254,"urlcode":"formulas","name":"Formulas"}]},{"discussionID":109474,"type":"question","name":"Help with date calculation formula","excerpt":"Hello, I'm trying to find a formula that will help me calculate how long an intake took to resolve. The rows I need to be calculated are Date Reported & Resolution Date. If the resolution date is blank I want it to use the current date in the calculation to see how long this issue has gone unresolved. Any help is much…","snippet":"Hello, I'm trying to find a formula that will help me calculate how long an intake took to resolve. The rows I need to be calculated are Date Reported & Resolution Date. If the…","categoryID":322,"dateInserted":"2023-08-25T16:29:39+00:00","dateUpdated":"2023-08-25T16:29:59+00:00","dateLastComment":"2023-08-25T23:01:30+00:00","insertUserID":165688,"insertUser":{"userID":165688,"name":"Nwest","title":"Systems Analyst","url":"https:\/\/community.smartsheet.com\/profile\/Nwest","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!ukHVZ18ImX4!BcjWAe8S9SY!l7iQo_PZHOx","dateLastActive":"2023-08-25T17:22:30+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":165688,"lastUserID":8888,"lastUser":{"userID":8888,"name":"Andrée Starå","title":"Smartsheet Expert Consultant & Partner | Workflow Consultant \/ CEO @ WORK BOLD","url":"https:\/\/community.smartsheet.com\/profile\/Andr%C3%A9e%20Star%C3%A5","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/0PAU3GBYQLBT\/nXWM7QXGD6464.jpg","dateLastActive":"2023-08-26T17:06:33+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":24,"score":null,"hot":3385987269,"url":"https:\/\/community.smartsheet.com\/discussion\/109474\/help-with-date-calculation-formula","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109474\/help-with-date-calculation-formula","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":109474,"commentID":392687,"name":"Re: Help with date calculation formula","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392687#Comment_392687","dateInserted":"2023-08-25T23:01:30+00:00","insertUserID":8888,"insertUser":{"userID":8888,"name":"Andrée Starå","title":"Smartsheet Expert Consultant & Partner | Workflow Consultant \/ CEO @ WORK BOLD","url":"https:\/\/community.smartsheet.com\/profile\/Andr%C3%A9e%20Star%C3%A5","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/0PAU3GBYQLBT\/nXWM7QXGD6464.jpg","dateLastActive":"2023-08-26T17:06:33+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-08-25T17:04:22+00:00","dateAnswered":"2023-08-25T16:36:59+00:00","acceptedAnswers":[{"commentID":392622,"body":"