Using MAX to get latest date by criteria

Hello,

I am trying get the latest date in a list, subject to criteria but MAX COLLECT does not seem to work. What am I doing wrong? I have tried both a text column and a date column.

=MAX(COLLECT({CQ Hours Data Range 6}, {CQ Hours Data Range 2}, Model@row, {CQ Hours Data Range 5}, Batch@row),)

Appreciate any suggestions!

Best Answers

  • Debbie Sawyer
    Debbie Sawyer ✭✭✭✭✭✭
    edited 07/21/23 Answer ✓

    @Jbob

    Thanks for the post. I have tried to recreate your example (in a simple way) to see where the issue is.

    In mine the column called Date and the column called Max per Value are BOTH Date data types.

    image.png

    I have exposed the formula I have used in the last column to show how the Max per Value is coming through.

    I know this has simplified your original question, but can you see how the Max(Collect()) statement works here?

    Does this help at all?

    So in yours:

    =MAX(COLLECT({CQ Hours Data Range 6}, {CQ Hours Data Range 2}, Model@row, {CQ Hours Data Range 5}, Batch@row),)

    Range 6 and the column you have written this formula into must be Date fields and you have an extra comma where you don't need it! Just between the last two )). This comma will cause an error.

    Kind regards

    Debbie

  • Jbob
    Jbob ✭✭
    Answer ✓

    Hello Debbie,

    Appreciate your help, that worked perfectly!

    Thank you!

Answers

  • Debbie Sawyer
    Debbie Sawyer ✭✭✭✭✭✭
    edited 07/21/23 Answer ✓

    @Jbob

    Thanks for the post. I have tried to recreate your example (in a simple way) to see where the issue is.

    In mine the column called Date and the column called Max per Value are BOTH Date data types.

    image.png

    I have exposed the formula I have used in the last column to show how the Max per Value is coming through.

    I know this has simplified your original question, but can you see how the Max(Collect()) statement works here?

    Does this help at all?

    So in yours:

    =MAX(COLLECT({CQ Hours Data Range 6}, {CQ Hours Data Range 2}, Model@row, {CQ Hours Data Range 5}, Batch@row),)

    Range 6 and the column you have written this formula into must be Date fields and you have an extra comma where you don't need it! Just between the last two )). This comma will cause an error.

    Kind regards

    Debbie

  • Jbob
    Jbob ✭✭
    Answer ✓

    Hello Debbie,

    Appreciate your help, that worked perfectly!

    Thank you!

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
HAS() will only return true under three conditions.<\/p>
  1. The cell is a multicontact cell and contains a match for the contact<\/li>
  2. The cell is a multiselect dropdown and contains a match<\/li>
  3. The cell is not a multicontact or multiselect dropdown and contains ONLY and EXACTLY the text you are matching against. <\/li><\/ol>

    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.<\/p>

    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.<\/p>

    =IF(CONTAINS(\" TAC \", [Column Name1]@row), 1, 0)<\/p>


    <\/p>

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

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


    <\/p>

    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.<\/p>

    =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)<\/p>


    <\/p>

    If there are 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.<\/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":109170,"type":"question","name":"COUNTIFS formula with 3 criteria (2 of the criteria have formulas)","excerpt":"Hi - I am trying to create a COUNTIFS formula using three criteria in the same sheet - Status (I just want to count the Open items), Impacted IT Projects (which is another dropdown of project names to select from), and Severity (this column displays a \"High\", \"Medium\", or \"Low\" value based on the calculated score in column…","snippet":"Hi - I am trying to create a COUNTIFS formula using three criteria in the same sheet - Status (I just want to count the Open items), Impacted IT Projects (which is another…","categoryID":322,"dateInserted":"2023-08-18T20:29:26+00:00","dateUpdated":null,"dateLastComment":"2023-08-18T21:13:12+00:00","insertUserID":165367,"insertUser":{"userID":165367,"name":"Shari D","url":"https:\/\/community.smartsheet.com\/profile\/Shari%20D","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-18T21:12:12+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-18T21:34:29+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":10,"countViews":92,"score":null,"hot":3384789758,"url":"https:\/\/community.smartsheet.com\/discussion\/109170\/countifs-formula-with-3-criteria-2-of-the-criteria-have-formulas","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109170\/countifs-formula-with-3-criteria-2-of-the-criteria-have-formulas","format":"Rich","lastPost":{"discussionID":109170,"commentID":391505,"name":"Re: COUNTIFS formula with 3 criteria (2 of the criteria have formulas)","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/391505#Comment_391505","dateInserted":"2023-08-18T21:13:12+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-18T21:34:29+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-18T21:12:26+00:00","dateAnswered":"2023-08-18T21:01:48+00:00","acceptedAnswers":[{"commentID":391499,"body":"

    @Shari D<\/a> My apologies, should have been HAS<\/p>

    =COUNTIFS(Status:Status, \"Open\", Severity:Severity, \"High\", [Impacted IT Projects]:[Impacted IT Projects], HAS(@cell, \"IT Project Name 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":[]},{"discussionID":109158,"type":"question","name":"Checkbox, Texts, RYG","excerpt":"I am trying to create a formula based on checkbox and dropdown list column. The result I am looking for is for Column 3 to have either a Red or Green symbol based on if Column 1 is checked OR Column 2 includes a specific word. Column 2 is a drop down with multiple options. Is this possible?","snippet":"I am trying to create a formula based on checkbox and dropdown list column. The result I am looking for is for Column 3 to have either a Red or Green symbol based on if Column 1…","categoryID":322,"dateInserted":"2023-08-18T16:30:48+00:00","dateUpdated":"2023-08-18T18:25:24+00:00","dateLastComment":"2023-08-18T21:05:50+00:00","insertUserID":160871,"insertUser":{"userID":160871,"name":"Nana250","url":"https:\/\/community.smartsheet.com\/profile\/Nana250","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-18T21:05:33+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":160871,"lastUserID":160871,"lastUser":{"userID":160871,"name":"Nana250","url":"https:\/\/community.smartsheet.com\/profile\/Nana250","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-18T21:05:33+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":6,"countViews":50,"score":null,"hot":3384772598,"url":"https:\/\/community.smartsheet.com\/discussion\/109158\/checkbox-texts-ryg","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109158\/checkbox-texts-ryg","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":109158,"commentID":391501,"name":"Re: Checkbox, Texts, RYG","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/391501#Comment_391501","dateInserted":"2023-08-18T21:05:50+00:00","insertUserID":160871,"insertUser":{"userID":160871,"name":"Nana250","url":"https:\/\/community.smartsheet.com\/profile\/Nana250","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-18T21:05: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-18T21:05:36+00:00","dateAnswered":"2023-08-18T21:02:55+00:00","acceptedAnswers":[{"commentID":391500,"body":"

    @Nana250<\/a> <\/p>

    Try this format and update columns names as needed: =IF(OR(CONTAINS(\"Insert Word\", [Column 2]@row), [Column 1]@row = 1), \"Green\", \"Red\")<\/p>

    If column 1 is checked or it finds the word in Column 2 it will go green, if not Red. Adjust as needed.<\/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"}]}],"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