Formula to show whichever is less
Hello,
I'm working on a formula to show the remaining duration of a task. I'd like to calculate workdays using the planned end date minus either today or the planned start date, whichever is closer to the planned end date. For example, if the planned start date is 10/29/21 and the planned end date is 11/05/21, then the formula would calculate the remaining workdays between today and 11/05/21. However, if the planned start date is 11/05/21 and the planned end date is 11/12/21, then the formula would calculate the number of workdays between 11/05 and 11/12. I'm stumped on how to write this formula. Any ideas?
Thanks!
Best Answer
-
You can use an IF statement for that.
If today is greater than the planned end, output zero, otherwise run the NETWORKDAYS calculation.
=IF(TODAY() >= [Planned End Date]@row, 0, NETWORKDAYS(MAX(TODAY(), [Planned Start Date]@row), [Planned End Date]@row))
Answers
-
So you essentially want to use the date that is greater (today or planned start)?
=NETWORKDAYS(MAX(TODAY(), [Planned Start Date]@row), [Planned End Date]@row)
-
@Paul Newcome Thank you! That worked perfectly. I have a follow up question. Do you know what I can add to the formula so that tasks in which the planned end has already passed show as 0 instead of a negative number?
-
You can use an IF statement for that.
If today is greater than the planned end, output zero, otherwise run the NETWORKDAYS calculation.
=IF(TODAY() >= [Planned End Date]@row, 0, NETWORKDAYS(MAX(TODAY(), [Planned Start Date]@row), [Planned End Date]@row))
-
@Paul Newcome Thank you so much! I really appreciate the help.
-
Happy to help. 👍️
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.3K Get Help
- 423 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 144 Just for fun
- 59 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 300 Events
- 39 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!