Partial match with INDEX(DISTINCT(COLLECT(

Hello,

I need to collect a list of values from my source sheet based on a search field (cell) in my target sheet. I have a very large subset of data that I'm pulling from, so I've divided it into 6 sheets to increase the speed of the lookup.

Currently, I'm using the formula: =IFERROR(IF(OR(LEFT([Lookup Value]$2, 1) = "A", LEFT([Lookup Value]$2, 1) = "B", LEFT([Lookup Value]$2, 1) = "C"), INDEX(DISTINCT(COLLECT({AttendeesConcat}, {A-C Last Name}, =[Lookup Value]$2)), [Primary Column]@row), ""), "")

This works, but you have to enter the full search term (last name). I'm trying to find a way to alter the formula to collect the cells based on a partial match.

Example: User enters Ad in the search field and the formula returns any values that contain Ad (Best case scenario would be if we can pull the results that start with the text string entered).

For the ideal solution, "Ad" would pull Adams, Adrien, Adios, etc.

Target Sheet:

image.png

Source Sheet: Trying to pull data from the Concatenated ID Column

image.png


Thank you!

Answers

  • jmyzk_cloudsmart_jp
    jmyzk_cloudsmart_jp ✭✭✭✭✭

    Hi@l.gann

    Here's my solution.

    Partial match with INDEX(DISTINCT(COLLECT( Demo DB.png


    1. Determining if a Name Starts with Certain Characters in Smartsheet

    我们需要确定目标的名字开始s with certain characters.

    Unfortunately, Smartsheet does not have the equivalent of Python' "startswith()" or Java Script's "startsWith()" methods.

    Method 1: Using LEFT and LEN functions.

    =IF(LEFT([Full Name]@row, LEN([Look Up Value]@row)) = [Look Up Value]@row, true, false)

    Method 2: Using the FIND function.

    =IF(FIND([Look Up Value]@row, [Full Name]@row) = 1, 1, 0)

    The difference is that the Find method is case-sensitive so this method would be more appropriate here.


    2. Selecting from Multiple Candidates:

    Since partial match gives you multiple candidates, you must determine how users select from the candidates.

    1. Concatenate the results using the CHAR(10) delimiter in a column.
    2. Place selection numbers in another column on the left side of the first.
    3. Use the selected number with the INDEX function to fetch the desired result.


    3. Demo Solution with Employee Data:

    The demo solution dashboard demonstrates the above with an example of employee data.

    Since the data is an employee directory, we do not have to use the DISTINCT function, but the demo works even with the function.

    The yellow cells are editable, so please check how the formulas work.


    Formulas

    Result List:

    =JOIN(DISTINCT(COLLECT({Full Name}, {Full Name}, FIND([Look Up Value]@row, @cell) = 1)), CHAR(10))

    Result Count

    =COUNT(DISTINCT(COLLECT({Full Name}, {Full Name}, FIND([Look Up Value]@row, @cell) = 1)))

    # (the selection number column)

    =JOIN(COLLECT({Index Number}, {Index Number}, <=[Result Count]@row), CHAR(10))

    Selected

    =IF(Selection@row > 0, INDEX(DISTINCT(COLLECT({Full Name}, {Full Name}, FIND([Look Up Value]@row, @cell) = 1)), Selection@row))


    If you need to access the demo contents, please complete the following form;

    (We create a copy of the contents folder and share the contents in the folder. Note: We can not share the folder.)

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
TODAY(), OR(Status@row <> \"Wrapped\", Status@row <>…","snippet":"Hello! I’m having trouble getting a flag to turn on if my Production Wraps column date is in the past and the status is NOT “wrapped” or “wrapped\/aired”. Here’s the formula I’m…","categoryID":322,"dateInserted":"2023-09-21T23:30:58+00:00","dateUpdated":null,"dateLastComment":"2023-09-22T00:21:06+00:00","insertUserID":167234,"insertUser":{"userID":167234,"name":"Will C","url":"https:\/\/community.smartsheet.com\/profile\/Will%20C","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-09-22T00:18:01+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":167234,"lastUser":{"userID":167234,"name":"Will C","url":"https:\/\/community.smartsheet.com\/profile\/Will%20C","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-09-22T00:18:01+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":19,"score":null,"hot":3390682324,"url":"https:\/\/community.smartsheet.com\/discussion\/110633\/how-do-you-set-a-flag-status-if-a-date-is-in-the-past-and-status-does-not-equal-a-certain-criteria","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/110633\/how-do-you-set-a-flag-status-if-a-date-is-in-the-past-and-status-does-not-equal-a-certain-criteria","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":110633,"commentID":396562,"name":"Re: How do you set a flag status if a date is in the past and status does not equal a certain criteria?","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/396562#Comment_396562","dateInserted":"2023-09-22T00:21:06+00:00","insertUserID":167234,"insertUser":{"userID":167234,"name":"Will C","url":"https:\/\/community.smartsheet.com\/profile\/Will%20C","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-09-22T00:18:01+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-09-22T00:20:03+00:00","dateAnswered":"2023-09-22T00:17:06+00:00","acceptedAnswers":[{"commentID":396561,"body":"

Hi @Will C<\/a> ,<\/p>

I'm not sure why you are getting #incorrect because your formula seems syntactically correct. It could be that you have a non-date in a date field?<\/p>

Having said that, if I'm reading your requirement correctly, that formula would not give the desired result. Try this and see if it's the results you are looking for.<\/p>

=IF(AND([Production Wraps]@row < TODAY(), Status@row <> \"Wrapped\", Status@row <> \"Wrapped\/Aired\"), 1, 0)<\/p>

Hope that helps,<\/p>

Dave<\/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":110618,"type":"question","name":"MAX DATE FROM 3 COLUMNS","excerpt":"Hi, On a separate sheet I would like to capture the max (or last) date from another sheet. As shown below, I would like to log the latest \"DATE OF VISIT\" from the 3 treatment columns. In this example the correct date would be 9\/06\/23. I've tried multiple versions of MAX(COLLECT but am only getting the first date, not the…","snippet":"Hi, On a separate sheet I would like to capture the max (or last) date from another sheet. As shown below, I would like to log the latest \"DATE OF VISIT\" from the 3 treatment…","categoryID":322,"dateInserted":"2023-09-21T20:55:50+00:00","dateUpdated":null,"dateLastComment":"2023-09-21T21:48:33+00:00","insertUserID":124866,"insertUser":{"userID":124866,"name":"Sam Lugiano","url":"https:\/\/community.smartsheet.com\/profile\/Sam%20Lugiano","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/EW9J0HEOWPA3\/nHSZYW5EKFGWU.jpg","dateLastActive":"2023-09-21T21:48:44+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"},"updateUserID":null,"lastUserID":124866,"lastUser":{"userID":124866,"name":"Sam Lugiano","url":"https:\/\/community.smartsheet.com\/profile\/Sam%20Lugiano","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/EW9J0HEOWPA3\/nHSZYW5EKFGWU.jpg","dateLastActive":"2023-09-21T21:48:44+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":19,"score":null,"hot":3390664463,"url":"https:\/\/community.smartsheet.com\/discussion\/110618\/max-date-from-3-columns","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/110618\/max-date-from-3-columns","format":"Rich","lastPost":{"discussionID":110618,"commentID":396551,"name":"Re: MAX DATE FROM 3 COLUMNS","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/396551#Comment_396551","dateInserted":"2023-09-21T21:48:33+00:00","insertUserID":124866,"insertUser":{"userID":124866,"name":"Sam Lugiano","url":"https:\/\/community.smartsheet.com\/profile\/Sam%20Lugiano","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/EW9J0HEOWPA3\/nHSZYW5EKFGWU.jpg","dateLastActive":"2023-09-21T21:48:44+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,"image":{"url":"https:\/\/us.v-cdn.net\/6031209\/uploads\/ZJ09BK0J5ZT3\/capture-jpg.jpg","urlSrcSet":{"10":"","300":"","800":"","1200":"","1600":""},"alt":"Capture.JPG"},"attributes":{"question":{"status":"accepted","dateAccepted":"2023-09-21T21:48:41+00:00","dateAnswered":"2023-09-21T21:13:16+00:00","acceptedAnswers":[{"commentID":396547,"body":"

@Sam Lugiano<\/a> What formula are you using? Does it matter which columns are checked, or if at least 1 is checked? I would recommend a helper column on this sheet that helps with the find. Name it Helper Date, or whatever you want. Set the formula to be<\/p>

=IFERROR(IF(COUNTIF([PAIN MGT INIT]@row:[PAIN MGT D\/C]@row, 1)>0, [DATE OF VISIT]@row),\"//m.santa-greenland.com/community/discussion/110045/\") <\/p>

Then where you are trying to grab the info you will use<\/p>

=MAX([HELPER DATE]:[HELPER DATE])<\/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":110591,"type":"question","name":"INVALID DATA TYPE Error in single cell of column formula","excerpt":"Hello, I am getting one cell returning the \"INVALID DATA TYPE\" error in a column formula. I have 159 rows in this sheet, and only one cell has the error, so I am very confused. The formulas is: =COUNTIFS({Site Visits Range 1}, Type@row, {Site Visits Range 3}, [Primary Column]@row, {Site Visits Range 2}, <>\"//m.santa-greenland.com/community/discussion/110045/\", {Site Visits…","snippet":"Hello, I am getting one cell returning the \"INVALID DATA TYPE\" error in a column formula. I have 159 rows in this sheet, and only one cell has the error, so I am very confused.…","categoryID":322,"dateInserted":"2023-09-21T16:33:29+00:00","dateUpdated":null,"dateLastComment":"2023-09-21T19:00:21+00:00","insertUserID":144966,"insertUser":{"userID":144966,"name":"kelceyg","title":"Associate Project Manager","url":"https:\/\/community.smartsheet.com\/profile\/kelceyg","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/QOWM4DMFF87J\/n3NJCD8AR6ZO1.jpg","dateLastActive":"2023-09-21T20:26:08+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭"},"updateUserID":null,"lastUserID":144966,"lastUser":{"userID":144966,"name":"kelceyg","title":"Associate Project Manager","url":"https:\/\/community.smartsheet.com\/profile\/kelceyg","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/QOWM4DMFF87J\/n3NJCD8AR6ZO1.jpg","dateLastActive":"2023-09-21T20:26:08+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":22,"score":null,"hot":3390638030,"url":"https:\/\/community.smartsheet.com\/discussion\/110591\/invalid-data-type-error-in-single-cell-of-column-formula","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/110591\/invalid-data-type-error-in-single-cell-of-column-formula","format":"Rich","tagIDs":[210,219,254,472],"lastPost":{"discussionID":110591,"commentID":396527,"name":"Re: INVALID DATA TYPE Error in single cell of column formula","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/396527#Comment_396527","dateInserted":"2023-09-21T19:00:21+00:00","insertUserID":144966,"insertUser":{"userID":144966,"name":"kelceyg","title":"Associate Project Manager","url":"https:\/\/community.smartsheet.com\/profile\/kelceyg","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/QOWM4DMFF87J\/n3NJCD8AR6ZO1.jpg","dateLastActive":"2023-09-21T20:26:08+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,"image":{"url":"https:\/\/us.v-cdn.net\/6031209\/uploads\/14XWFKFS2BZO\/sheet.jpg","urlSrcSet":{"10":"","300":"","800":"","1200":"","1600":""},"alt":"sheet.jpg"},"attributes":{"question":{"status":"accepted","dateAccepted":"2023-09-21T19:02:19+00:00","dateAnswered":"2023-09-21T17:17:11+00:00","acceptedAnswers":[{"commentID":396499,"body":"

@kelceyg<\/a> <\/p>

Only thing that sticks out is the YEAR() function.<\/p>

Check {Site Visits Range 2} sheet and add a column there with the year function and see if anything is giving you an error.<\/p>

This could mean it does not have a proper date in the cell.<\/p>

You could also add an IFERROR() in your formula to ignore them: IFERROR(YEAR(@cell),0) = 2023<\/strong><\/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":210,"urlcode":"human-resources","name":"Human Resources"},{"tagID":219,"urlcode":"sheets","name":"Sheets"},{"tagID":254,"urlcode":"formulas","name":"Formulas"},{"tagID":472,"urlcode":"cell-linking","name":"Cell linking"}]}],"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