How to check a box if exact text is found within a string of text

你好,我试着g to place a check in a box when some exact text is found within a string of words. I am looking to place a check when "TAC" is found in a string of words.

Here's the formula I am using, but its not working. No error message, but is not selecting the checkbox appropriately.

=IF(HAS([Column Name1]@row, "TAC"), 1, 0)

I was using "Contains" rather than "HAS" but that formula checked the box for all words that contained "TAC" not just the ones that matched exactly. I am stumped why HAS doesn't seem to work the same way.

Is it because "HAS" only works if the word "TAC" is the only word present? The Column Name1 is a drop down column that's populated with content like this: Location Name Medical Center TAC

I just need a box checked if and exact match for the word "TAC" is found within the text string. I tried True and False in a drop down and didn't have any luck with that either.

Thank you for any assistance you can provide!

标签:

Best Answer

  • Carson Penticuff
    Carson Penticuff ✭✭✭✭✭✭
    Answer ✓

    HAS() will only return true under three conditions.

    1. The cell is a multicontact cell and contains a match for the contact
    2. The cell is a multiselect dropdown and contains a match
    3. The cell is not a multicontact or multiselect dropdown and contains ONLY and EXACTLY the text you are matching against.

    I am assuming your row in question is a standard Text/Number cell? If so, you will need to get somewhat creative with some CONTAINS() statements.

    This will narrow down your matches to only cells that contain a space both before and after TAC. If, however, TAC can appear as the first or last "word" in the cell, it would not match in that circumstance as there would only be a space on one side.

    =IF(CONTAINS(" TAC ", [Column Name1]@row), 1, 0)


    If TAC can appear as the first or last "word" in the cell, this will cover those possibilities as well.

    =IF(OR(CONTAINS(" TAC ", [Column Name1]@row), LEFT([Column Name1]@row, 4) = "TAC ", RIGHT([Column Name1]@row, 4) = " TAC"), 1, 0)


    If it is possible that TAC will be the exact entry of the cell, you will need an additional statement to cover that, as there would not be spaces on either side. This will add that option.

    =IF(OR(CONTAINS(" TAC ", [Column Name1]@row), LEFT([Column Name1]@row, 4) = "TAC ", RIGHT([Column Name1]@row, 4) = " TAC", [Column Name1]@row = "TAC"), 1, 0)


    如果有other situations you may have in your sheet, i.e., TAC inside parenthesis, or before or after punctuation, etc, you will additional statements to include those options as well.

Answers

  • Carson Penticuff
    Carson Penticuff ✭✭✭✭✭✭
    Answer ✓

    HAS() will only return true under three conditions.

    1. The cell is a multicontact cell and contains a match for the contact
    2. The cell is a multiselect dropdown and contains a match
    3. The cell is not a multicontact or multiselect dropdown and contains ONLY and EXACTLY the text you are matching against.

    I am assuming your row in question is a standard Text/Number cell? If so, you will need to get somewhat creative with some CONTAINS() statements.

    This will narrow down your matches to only cells that contain a space both before and after TAC. If, however, TAC can appear as the first or last "word" in the cell, it would not match in that circumstance as there would only be a space on one side.

    =IF(CONTAINS(" TAC ", [Column Name1]@row), 1, 0)


    If TAC can appear as the first or last "word" in the cell, this will cover those possibilities as well.

    =IF(OR(CONTAINS(" TAC ", [Column Name1]@row), LEFT([Column Name1]@row, 4) = "TAC ", RIGHT([Column Name1]@row, 4) = " TAC"), 1, 0)


    If it is possible that TAC will be the exact entry of the cell, you will need an additional statement to cover that, as there would not be spaces on either side. This will add that option.

    =IF(OR(CONTAINS(" TAC ", [Column Name1]@row), LEFT([Column Name1]@row, 4) = "TAC ", RIGHT([Column Name1]@row, 4) = " TAC", [Column Name1]@row = "TAC"), 1, 0)


    如果有other situations you may have in your sheet, i.e., TAC inside parenthesis, or before or after punctuation, etc, you will additional statements to include those options as well.

  • Jen H.
    Jen H. ✭✭
    edited 08/19/23

    EUREKA! That works - I chose this option; =IF(CONTAINS(" TAC ", [Column Name1]@row), 1, 0) and because the word TAC was at the end of the text stream, I edited the above slightly by removing the space after "TAC" but keeping the space in front of it. This made the formula =IF(CONTAINS(" TAC", [Column Name1]@row), 1, 0) and it worked beautifully! Thank you so so much on behalf of me and the entire team.

    Warmly, Jen

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
If your column title contains a space, it must be surrounded with square brackets. This should fix it.<\/p>

=COUNTIFS(PNS@row, 1) + COUNTIFS(EIP@row, 1) + COUNTIFS(Facilities@row, 1) + COUNTIFS([Patient Care Experience]@row, 1)<\/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":109375,"type":"question","name":"Calculate number of days and years from start date","excerpt":"I need to see how long staff have been with us, their tenure. I need this for any given dates, meaning \"today\". I have the start date, how do I get the days from that in years and days? Example: Start date is 06\/01\/2020, today is 08\/23\/2023 so the Tenure should be 3 years, 2 months, 22 days. I would take 3.2","snippet":"I need to see how long staff have been with us, their tenure. I need this for any given dates, meaning \"today\". I have the start date, how do I get the days from that in years and…","categoryID":322,"dateInserted":"2023-08-24T01:42:08+00:00","dateUpdated":null,"dateLastComment":"2023-08-24T15:05:11+00:00","insertUserID":82351,"insertUser":{"userID":82351,"name":"Leann Gibson","url":"https:\/\/community.smartsheet.com\/profile\/Leann%20Gibson","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/drupal_profile\/files\/2019-04\/7e\/c6\/n7ec6db531603daaefab20990ddcfdd53.jpg","dateLastActive":"2023-08-24T17:16:24+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭"},"updateUserID":null,"lastUserID":82351,"lastUser":{"userID":82351,"name":"Leann Gibson","url":"https:\/\/community.smartsheet.com\/profile\/Leann%20Gibson","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/drupal_profile\/files\/2019-04\/7e\/c6\/n7ec6db531603daaefab20990ddcfdd53.jpg","dateLastActive":"2023-08-24T17:16:24+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":44,"score":null,"hot":3385732039,"url":"https:\/\/community.smartsheet.com\/discussion\/109375\/calculate-number-of-days-and-years-from-start-date","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109375\/calculate-number-of-days-and-years-from-start-date","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":109375,"commentID":392349,"name":"Re: Calculate number of days and years from start date","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392349#Comment_392349","dateInserted":"2023-08-24T15:05:11+00:00","insertUserID":82351,"insertUser":{"userID":82351,"name":"Leann Gibson","url":"https:\/\/community.smartsheet.com\/profile\/Leann%20Gibson","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/drupal_profile\/files\/2019-04\/7e\/c6\/n7ec6db531603daaefab20990ddcfdd53.jpg","dateLastActive":"2023-08-24T17:16:24+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-24T15:05:21+00:00","dateAnswered":"2023-08-24T15:05:11+00:00","acceptedAnswers":[{"commentID":392349,"body":"

That worked perfectly, 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":[{"tagID":254,"urlcode":"formulas","name":"Formulas"}]},{"discussionID":109369,"type":"question","name":"INDEXING and Validating","excerpt":"I have a perplexing question, that I am sure someone knows and I am missing here. I am working on a sheet to gather data from a form. However, this form will get quite lengthily and may span multiple years. With that said this is where I am stumped. =INDEX(COLLECT({Test Sheet 1 Range 1}, {Test Sheet 1 Range 1}, <> \"//www.santa-greenland.com/community/discussion/109176/\"),…","snippet":"I have a perplexing question, that I am sure someone knows and I am missing here. I am working on a sheet to gather data from a form. However, this form will get quite lengthily…","categoryID":322,"dateInserted":"2023-08-23T21:21:49+00:00","dateUpdated":null,"dateLastComment":"2023-08-24T14:04:04+00:00","insertUserID":163519,"insertUser":{"userID":163519,"name":"Frank Hammond","title":"Mr.","url":"https:\/\/community.smartsheet.com\/profile\/Frank%20Hammond","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/avatarstock\/nWVKDFTEFOKBN.png","dateLastActive":"2023-08-24T15:23:34+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"},"updateUserID":null,"lastUserID":163506,"lastUser":{"userID":163506,"name":"JamesB","title":"IT Project Manager","url":"https:\/\/community.smartsheet.com\/profile\/JamesB","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/avatarstock\/nEQMY42MFGXWS.png","dateLastActive":"2023-08-24T18:14:37+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":48,"score":null,"hot":3385713353,"url":"https:\/\/community.smartsheet.com\/discussion\/109369\/indexing-and-validating","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109369\/indexing-and-validating","format":"Rich","lastPost":{"discussionID":109369,"commentID":392314,"name":"Re: INDEXING and Validating","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392314#Comment_392314","dateInserted":"2023-08-24T14:04:04+00:00","insertUserID":163506,"insertUser":{"userID":163506,"name":"JamesB","title":"IT Project Manager","url":"https:\/\/community.smartsheet.com\/profile\/JamesB","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/avatarstock\/nEQMY42MFGXWS.png","dateLastActive":"2023-08-24T18:14:37+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-23T21:50:04+00:00","dateAnswered":"2023-08-23T21:43:36+00:00","acceptedAnswers":[{"commentID":392246,"body":"

@Frank Hammond<\/a> <\/p>

Your formula is close, looks like you just need commas between your criterion range and criterion.<\/p>

=INDEX(COLLECT({Test Sheet 1 Range 1}, {Test Sheet 1 Range 2}, = 9, {Test Sheet 1 Range 3}, = 2023), Index@row)<\/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":[]}],"initialPaging":{"nextURL":"https:\/\/community.smartsheet.com\/api\/v2\/discussions?page=2&categoryID=322&includeChildCategories=1&type%5B0%5D=Question&excludeHiddenCategories=1&sort=-hot&limit=3&expand%5B0%5D=all&expand%5B1%5D=-body&expand%5B2%5D=insertUser&expand%5B3%5D=lastUser&status=accepted","prevURL":null,"currentPage":1,"total":10000,"limit":3},"title":"Trending in Formulas and Functions ","subtitle":null,"description":null,"noCheckboxes":true,"containerOptions":[],"discussionOptions":[]}">

Trending in Formulas and Functions