Calculations with dates

I need help figuring out date calculations. I've tried many different things and nothing works so far.


I have a list of projects, each project has a list of tasks with start and due dates. I need to calculate the difference between the start date of one task and end date of another task (always the same 2 tasks). In my screenshot, for each project, I want the difference (in days) between Start of Design and End of Plan. I have the desired results displayed on the right (just did a manual calculation, but that won't work because this database is huge!).


Problem is, there are thousands of rows with same project names and same task names. No project has the same task twice , which is very helpful. So I need to have a formula that will let me calculate between dates with conditions:

  • Condition 1: Task Name must match "Design" to get the first date
  • Condition 2: Task Name must match "Plan" to get the second date
  • Condition 3: Both of the above must have Project Name that matches project name @ row
  • Then need to subtract one date that meets the above conditions from the other date that meets the above conditions.

I don't know how to do this, I have tried many different formulas and none of them work because once you start playing with index/match/join/collect, dates get converted into text and no calculations can be made.


Any input is appreciated. I would like to do this with one formula because I already have so many different columns that I really don't want to add any additional ones!


PS - these are true date columns and dates are input manually so calculations between start date and due date column shouldn't pose an issue, there is no formula in those columns.


TIA!

Dates.PNG


Answers

  • David Joyeuse
    David Joyeuse ✭✭✭✭✭

    Hi@Melisa Dannhauser

    How about this:

    =DATE(COLLECT({Due Date Range}, {Project Name Range}, [Project]@row, {Task Name Range}, "Plan") - DATE(COLLECT({Start Date Range}, {Project Name Range}, [Project]@row, "Design")

    let me know how this works.

    Hope it helped!

  • Melisa Dannhauser
    edited 09/28/20

    @David JoyeuseThat doesn't work unfortunately. = Date(collect) is expecting a date entry so when I finish entering the first part of the formula, it thinks that's the year and it wants me to now enter month and day... See screenshot. Any other suggestions? I tried using MIN(collect) but I have the same issue as always - the returned date isn't really recognized as a date so I can't perform a calculation. I have no idea if what I'm trying to do is possible :(


    These are my actual column names below.

    Dates2.PNG


  • Melisa Dannhauser
    edited 09/28/20

    啊,玩后,我意识到MIN(COLLECT) does work! I just had the column formatted as a date so it kept saying "date expected". After formatting column as text/number, the calculation did work! Thanks a lot for pointing me in the right direction with collect! :)


    My working formula looks exactly like David's above except I replaced DATE with MIN :)

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out theFormula Handbook template!
=JOIN(COLLECT([Key Supplier]:[Key Supplier], [Part Number]:[Part Number], HAS([Part Numbers]@row, @cell)), \", \")<\/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"},{"tagID":391,"urlcode":"product-development","name":"Product Development"}]},{"discussionID":107971,"type":"question","name":"IF OR Statement Return False Value","excerpt":"Hi...I'm looking to close a simple IF OR statement and it seems I'm missing something. 2 values where if 1 or the other is less than 0 return \"Red\" if false \"Green\" and returning Green is just getting an error, here is what I have: =IF(OR(IDEA34 < 0, IDEA58 < 0, \"Red\", (\"Green\"))) #incorrect argument😫","snippet":"Hi...I'm looking to close a simple IF OR statement and it seems I'm missing something. 2 values where if 1 or the other is less than 0 return \"Red\" if false \"Green\" and returning…","categoryID":322,"dateInserted":"2023-07-24T13:36:30+00:00","dateUpdated":null,"dateLastComment":"2023-07-24T14:28:58+00:00","insertUserID":125719,"insertUser":{"userID":125719,"name":"John Littler","url":"https:\/\/community.smartsheet.com\/profile\/John%20Littler","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!wpNNPwQhvfo!uidap8QQmDo!EZ4Jh41s4vN","dateLastActive":"2023-07-24T15:49:31+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭"},"updateUserID":null,"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-07-24T21:09:47+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":21,"score":null,"hot":3380416528,"url":"https:\/\/community.smartsheet.com\/discussion\/107971\/if-or-statement-return-false-value","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/107971\/if-or-statement-return-false-value","format":"Rich","lastPost":{"discussionID":107971,"commentID":386640,"name":"Re: IF OR Statement Return False Value","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/386640#Comment_386640","dateInserted":"2023-07-24T14:28:58+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-07-24T21:09:47+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-07-24T13:49:52+00:00","dateAnswered":"2023-07-24T13:39:05+00:00","acceptedAnswers":[{"commentID":386625,"body":"

Hi @John Littler<\/a> <\/p>

I hope you're well and safe!<\/p>

Try something like this.<\/p>

=IF(OR(Idea34 = \"//www.santa-greenland.com/community/discussion/71617/\", Idea58 = \"//www.santa-greenland.com/community/discussion/71617/\"), \"//www.santa-greenland.com/community/discussion/71617/\", IF(OR(Idea34 < 0, Idea58 < 0), \"Red\", \"Green\"))\n<\/pre>

Did that work\/help? <\/p>

I hope that helps!<\/p>

Be safe, and have a fantastic week!<\/p>

Best,<\/p>

Andrée Starå<\/strong><\/a> | Workflow Consultant \/ CEO @ WORK BOLD<\/strong><\/a><\/p>

Did my post(s) help or answer your question or solve your problem? Please support the Community by <\/em>marking it Insightful\/Vote Up, Awesome, or\/and as the accepted answer<\/em><\/strong>. It will make it easier for others to find a solution or help to answer!<\/em><\/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":107942,"type":"question","name":"How do I return DISTINCT values from another sheet based on specific dates within that sheet?","excerpt":"Hello, I have a need to return a Distinct Item ID from another sheet based on a date range from another date column within that same external sheet. The formula below works; however, once I run out of Distinct item IDs that meet my date criteria it continues to return results that fall outside that date range. Current…","snippet":"Hello, I have a need to return a Distinct Item ID from another sheet based on a date range from another date column within that same external sheet. The formula below works;…","categoryID":322,"dateInserted":"2023-07-22T00:19:14+00:00","dateUpdated":null,"dateLastComment":"2023-07-24T14:28:01+00:00","insertUserID":123219,"insertUser":{"userID":123219,"name":"Matt Foss","url":"https:\/\/community.smartsheet.com\/profile\/Matt%20Foss","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!bCFRG7SgS_o!w6Nev-KRhHQ!jkKTibQm-FP","dateLastActive":"2023-07-24T14:20:31+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-07-24T22:45:28+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":32,"score":null,"hot":3380195835,"url":"https:\/\/community.smartsheet.com\/discussion\/107942\/how-do-i-return-distinct-values-from-another-sheet-based-on-specific-dates-within-that-sheet","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/107942\/how-do-i-return-distinct-values-from-another-sheet-based-on-specific-dates-within-that-sheet","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":107942,"commentID":386638,"name":"Re: How do I return DISTINCT values from another sheet based on specific dates within that sheet?","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/386638#Comment_386638","dateInserted":"2023-07-24T14:28:01+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-07-24T22:45:28+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\/74OMVUEY31TO\/example.png","urlSrcSet":{"10":"","300":"","800":"","1200":"","1600":""},"alt":"Example.png"},"attributes":{"question":{"status":"accepted","dateAccepted":"2023-07-24T14:20:29+00:00","dateAnswered":"2023-07-22T02:23:22+00:00","acceptedAnswers":[{"commentID":386531,"body":"

I think this is what you are trying to accomplish. I assume you are dragging the formula down, as this will not work as a column formula due to the absolute references. There were a few issues with the formula you posted, maybe there were some typos when transferring it to your post? <\/p>

=IFERROR(INDEX(DISTINCT(COLLECT({Item ID}, {Create Date}, >= $[Start Date]$1, {Create Date}, <= $[End Date]$1)), [Row ID]@row), \"//www.santa-greenland.com/community/discussion/71617/\")<\/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