Check if project start/end dates fall within specific time frame.

gunnell
gunnell
edited 06/08/23 inFormulas and Functions

My team works on projects that typically take 6-12 months. I'd like to create a roll-up sheet that identifies which quarters in which a project was worked on. I'm creating a new row for each project and linking in the start and end dates from each of the projects' sheets. Then I've created a new column for each quarter (e.g., 2022Q1, 2022Q2, 2022Q3, 2022Q4, 2023Q1...)

Let's say "Project 1" started on Oct 4, 2022 and ended on May 15, 2023.

I'm trying to create a formula that would go in those quarter cells that asks if the dates of the quarter (e.g., 1/1/2022 through 3/31/2022) overlap at all with the dates of the project. If it does, throw a 1 in the cell for that quarter, of not, 0.

So for the Project 1 row, the following columns would have a 1: 2022Q4, 2023Q1, 2023Q2 since the project dates overlap with those quarters. The rest of the columns (for the other quarters) would all be 0.

It seems simple, but I can't seem to get the IF(AND()) formulas working.

Thanks!

Best Answers

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭
    Answer ✓

    Try something like this:

    =IF(AND([End Date]@row>= DATE(quarter start date), [Start Date]@row<= DATE(quarter end date)), 1)


    Using the proper syntax to input the appropriate quarter start and end dates should get you what you are looking for.

    DATE(yyyy, mm, dd)

  • gunnell
    gunnell
    Answer ✓
    Try something like this:<\/p>

    =IF(AND([End Date]@row>= DATE(quarter start date), [Start Date]@row<= DATE(quarter end date)), 1)<\/p>

    Using the proper syntax to input the appropriate quarter start and end dates should get you what you are looking for.<\/p>

    DATE(yyyy, mm, dd)<\/p>","bodyRaw":"[{\"insert\":\"Try something like this:\\n=IF(AND([End Date]@row>= DATE(quarter start date), [Start Date]@row<= DATE(quarter end date)), 1)\\n\\nUsing the proper syntax to input the appropriate quarter start and end dates should get you what you are looking for.\\nDATE(yyyy, mm, dd)\\n\"}]","format":"rich","dateInserted":"2023-06-09T13:54:21+00:00","insertUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-08-03T13:06:14+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"displayOptions":{"showUserLabel":false,"showCompactUserInfo":true,"showDiscussionLink":false,"showPostLink":false,"showCategoryLink":false,"renderFullContent":false,"expandByDefault":false},"url":"https:\/\/community.smartsheet.com\/discussion\/comment\/379822#Comment_379822","embedType":"quote"}"> https://community.smartsheet.com/discussion/comment/379822#Comment_379822

    The problem I was having with something similar to what you have is that it wasn't picking up projects that started before the quarter and ended after the quarter. So if project started in 2022Q4, continued in 2023Q1, and ended during 2023Q2, I would want a "1" for all three quarters but it was only giving me one for 2022Q4 and 2023Q2 (skipping 2023Q1).

    I actually just got this working late last night (with the help of ChatGPT). Here is what I ended up with. This one checks for 2022Q1.

    =IF(OR(AND([email protected]<= DATE(2022, 3, 31),[email protected]>= DATE(2022, 1, 1)), AND(DATE(2022, 1, 1) <=[email protected], DATE(2022, 3, 31) >=[email protected])), 1, 0)

Answers

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭
    Answer ✓

    Try something like this:

    =IF(AND([End Date]@row>= DATE(quarter start date), [Start Date]@row<= DATE(quarter end date)), 1)


    Using the proper syntax to input the appropriate quarter start and end dates should get you what you are looking for.

    DATE(yyyy, mm, dd)

  • gunnell
    gunnell
    Answer ✓
    Try something like this:<\/p>

    =IF(AND([End Date]@row>= DATE(quarter start date), [Start Date]@row<= DATE(quarter end date)), 1)<\/p>

    Using the proper syntax to input the appropriate quarter start and end dates should get you what you are looking for.<\/p>

    DATE(yyyy, mm, dd)<\/p>","bodyRaw":"[{\"insert\":\"Try something like this:\\n=IF(AND([End Date]@row>= DATE(quarter start date), [Start Date]@row<= DATE(quarter end date)), 1)\\n\\nUsing the proper syntax to input the appropriate quarter start and end dates should get you what you are looking for.\\nDATE(yyyy, mm, dd)\\n\"}]","format":"rich","dateInserted":"2023-06-09T13:54:21+00:00","insertUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-08-03T13:06:14+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"displayOptions":{"showUserLabel":false,"showCompactUserInfo":true,"showDiscussionLink":false,"showPostLink":false,"showCategoryLink":false,"renderFullContent":false,"expandByDefault":false},"url":"https:\/\/community.smartsheet.com\/discussion\/comment\/379822#Comment_379822","embedType":"quote"}"> https://community.smartsheet.com/discussion/comment/379822#Comment_379822

    The problem I was having with something similar to what you have is that it wasn't picking up projects that started before the quarter and ended after the quarter. So if project started in 2022Q4, continued in 2023Q1, and ended during 2023Q2, I would want a "1" for all three quarters but it was only giving me one for 2022Q4 and 2023Q2 (skipping 2023Q1).

    I actually just got this working late last night (with the help of ChatGPT). Here is what I ended up with. This one checks for 2022Q1.

    =IF(OR(AND([email protected]<= DATE(2022, 3, 31),[email protected]>= DATE(2022, 1, 1)), AND(DATE(2022, 1, 1) <=[email protected], DATE(2022, 3, 31) >=[email protected])), 1, 0)

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

    @gunnellThe key to mine is comparing [End Date] to after the START of the quarter and [Start Date] to before the END of the quarter. This takes care of any overlap and will pick up everything in between with only two pieces to the AND function instead of 4 with the OR.

  • @Paul NewcomeYes! Simple is better! Thank you!

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
You would have to insert a new header field into the form that has that particular verbiage formatted the way you want then use the form field logic to display this header row if one of the incorrect answers is selected.<\/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":108403,"type":"question","name":"Date formula to set cut off period","excerpt":"I am trying to set a date formula to for the following statement; if the [Next Due Date] is <= 27\/07\/2023 return \"Performed\" Example: =IF(ISBLANK([Last inspection]@row), \"\", IF(DATE(2023,7,27)) < [Next Due Date]@row, \"Overdue\", \"Performed\"))","snippet":"I am trying to set a date formula to for the following statement; if the [Next Due Date] is <= 27\/07\/2023 return \"Performed\" Example: =IF(ISBLANK([Last inspection]@row), \"\",…","categoryID":322,"dateInserted":"2023-08-02T11:05:55+00:00","dateUpdated":"2023-08-02T11:35:37+00:00","dateLastComment":"2023-08-03T08:51:04+00:00","insertUserID":125711,"insertUser":{"userID":125711,"name":"Adedeji Adebanjo","url":"https:\/\/community.smartsheet.com\/profile\/Adedeji%20Adebanjo","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!ZrfDGXkxfL4!BfDCQc0uMJQ!nMYqiMpYuek","dateLastActive":"2023-08-03T10:26:54+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭"},"updateUserID":91566,"lastUserID":125711,"lastUser":{"userID":125711,"name":"Adedeji Adebanjo","url":"https:\/\/community.smartsheet.com\/profile\/Adedeji%20Adebanjo","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!ZrfDGXkxfL4!BfDCQc0uMJQ!nMYqiMpYuek","dateLastActive":"2023-08-03T10:26:54+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":19,"score":null,"hot":3382028219,"url":"https:\/\/community.smartsheet.com\/discussion\/108403\/date-formula-to-set-cut-off-period","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/108403\/date-formula-to-set-cut-off-period","format":"Rich","lastPost":{"discussionID":108403,"commentID":388644,"name":"Re: Date formula to set cut off period","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/388644#Comment_388644","dateInserted":"2023-08-03T08:51:04+00:00","insertUserID":125711,"insertUser":{"userID":125711,"name":"Adedeji Adebanjo","url":"https:\/\/community.smartsheet.com\/profile\/Adedeji%20Adebanjo","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!ZrfDGXkxfL4!BfDCQc0uMJQ!nMYqiMpYuek","dateLastActive":"2023-08-03T10:26:54+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-03T08:50:18+00:00","dateAnswered":"2023-08-02T12:58:11+00:00","acceptedAnswers":[{"commentID":388454,"body":"

Try removing one of the closing parenthesis after the DATE function.<\/p>"},{"commentID":388644,"body":"

Thanks! That sorted it!😀<\/span><\/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":108391,"type":"question","name":"Can I use groups to create series?","excerpt":"I have this report and from this I have created this Chart but I want it to drill down to the show the individual Branches on a stacked column chart like this. is this at all possible?","snippet":"I have this report and from this I have created this Chart but I want it to drill down to the show the individual Branches on a stacked column chart like this. is this at all…","categoryID":322,"dateInserted":"2023-08-02T02:31:48+00:00","dateUpdated":"2023-08-02T11:36:34+00:00","dateLastComment":"2023-08-03T13:06:28+00:00","insertUserID":163489,"insertUser":{"userID":163489,"name":"Benny C","url":"https:\/\/community.smartsheet.com\/profile\/Benny%20C","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!xq_RMfil_3w!!B9mU9H6NId1","dateLastActive":"2023-08-03T00:58:31+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":91566,"lastUserID":45516,"lastUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-08-03T13:06:14+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":25,"score":null,"hot":3382013296,"url":"https:\/\/community.smartsheet.com\/discussion\/108391\/can-i-use-groups-to-create-series","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/108391\/can-i-use-groups-to-create-series","format":"Rich","lastPost":{"discussionID":108391,"commentID":388682,"name":"Re: Can I use groups to create series?","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/388682#Comment_388682","dateInserted":"2023-08-03T13:06:28+00:00","insertUserID":45516,"insertUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-08-03T13:06:14+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\/UYHRDRG9I6TS\/image.png","urlSrcSet":{"10":"","300":"","800":"","1200":"","1600":""},"alt":"image.png"},"attributes":{"question":{"status":"accepted","dateAccepted":"2023-08-03T00:59:37+00:00","dateAnswered":"2023-08-02T12:47:07+00:00","acceptedAnswers":[{"commentID":388443,"body":"

This isn't possible in a report. You would have to use a specifically structured metrics sheet with cross sheet references pulling in your totals.<\/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