Formula Help Within Sheet
Alright, SmartSheet community. You've always been good to me with helping out. I've got a real "stumper" here.
Let's say I have six columns on my sheet (in reality there's many, many more; but these are the ones relevant to my question):
- Start Date (a Date/Time column type)
- End Date (a Date/Time column type)
- Allocation % (a Text/Number column date that is in a % format, like 70%)
- February 2023 Hours Scheduled (a formula driven cell)
- March 2023 Hours Scheduled (a formula driven cell)
- April 2023 Hours Scheduled (a formula driven cell)
Now, let's assume that the Start Date is set to 02/01/2023 and the End Date is set to 04/30/2023. I need a formula in Column 4 (February 2023 Hours Scheduled) that calculates the number of working days in February (19) within the Start Date and End Date multiplied by the Allocation % cell and then multiplied by 8.
This will give me the number of hours I need to devote in February for an employee who is working 70% of their time towards this line item.
I'd need to be able to then copy/adjust this formula for the March 2023 column and then again to the April 2023 column.
Alright, please do your thing. Many thanks.
Best Answer
-
Try this:
=IFERROR(NETWORKDAYS(IF([Start Date]@row < DATE(2023, 2, 1), DATE(2023, 2, 1), IF([Start Date]@row > DATE(2023, 2, 28), "", [Start Date]@row)), IF([End Date]@row < DATE(2023, 2, 1), "", IF([End Date]@row < DATE(2023, 2, 28), [End Date]@row, DATE(2023, 2, 28)))) * [Allocation %]@row * 8, "No Feb 2023 Work Days")
Answers
-
Will your start and end dates always be Feb - Mar? Are you only calculating for Feb - Mar, or does this expand to more month columns? If there are more month columns, do you need to be able to account for going into another year?
Come see me in Seattle at ENGAGE 2024! I will be at the 10xViz partner booth throughout as well as the "Lets Talk About Community" Meet & Eat table on Tuesday from 11:45am - 12:45pm!
-
Thanks, Paul. No, the February through April dates I gave in my example are just an example. The real life sheet will have dates spanning all months and into future years (there are columns for "February 2023, March 2023, April 2023, May 2023, through many years". So, perhaps the formula will have to designate both Month and Year. I hope this helps. Thanks for looking into this.
-
Ok. There are a number of other posts here in the Community that have the base already built out where we spread the number of days across multiple columns. I remember helping out on a few, so we just need to find one and then tweak it. If you happen to find one of those posts before I do, feel free to drop a link here and we can work it from there.
Come see me in Seattle at ENGAGE 2024! I will be at the 10xViz partner booth throughout as well as the "Lets Talk About Community" Meet & Eat table on Tuesday from 11:45am - 12:45pm!
-
Hello, Paul (or anyone else),
I'm writing to follow-up on this thread. I've searched through the history of similar issues, and I found a thread from April 2022 (thread titled "Formula for Hours Scheduled By Month") and came across the below formula. When applied, it's not quite there yet (giving me error messages). I'm hoping this maybe jogs your memory and you can help modify the below formula to my issues. Thanks.
=IF(MONTH([Start Date]@row) = 3, NETWORKDAYS([Start Date]@row, IFERROR(DATE(YEAR([Start Date]@row), MONTH([Start Date]@row) + 1, 1), DATE(YEAR([Start Date]@row) + 1, 1, 1)) - 1) + " days & " + (NETWORKDAYS([Start Date]@row, IFERROR(DATE(YEAR([Start Date]@row), MONTH([Start Date]@row) + 1, 1), DATE(YEAR([Start Date]@row) + 1, 1, 1)) - 1) * [Hours per Day]@row) + " hours", IF(MONTH([End Date]@row) = 3, NETWORKDAYS(DATE(2022, 03, 01), [End Date]@row) + " days & " + (NETWORKDAYS(DATE(2022, 03, 01), [End Date]@row) * [Hours per Day]@row) + " hours", IF(AND([Start Date]@row < DATE(2022, 03, 01), [End Date]@row > IFERROR(DATE(YEAR([Start Date]@row), MONTH([Start Date]@row) + 1, 1), DATE(YEAR([Start Date]@row) + 1, 1, 1)) - 1), NETWORKDAYS(DATE(2022, 03, 01), IFERROR(DATE(YEAR([Start Date]@row), MONTH([Start Date]@row) + 1, 1), DATE(YEAR([Start Date]@row) + 1, 1, 1)) - 1) + " days & " + (NETWORKDAYS(DATE(2022, 03, 01), IFERROR(DATE(YEAR([Start Date]@row), MONTH([Start Date]@row) + 1, 1), DATE(YEAR([Start Date]@row) + 1, 1, 1)) - 1) * [Hours per Day]@row) + " hours")))
-
Does this work?
=IFERROR(NETWORKDAYS(IF([Start Date]@row < DATE(2023, 2, 1), DATE(2023, 2, 1), IF([Start Date]@row > DATE(2023, 2, 28), "", [Start Date]@row)), DATE(2023, 2, 28)), "No Feb 2023 Work Days") * [Allocation %]@row * 8
-
I forgot I changed something which broke the IFERROR. This is what I was going for:
=IFERROR(NETWORKDAYS(IF([Start Date]@row < DATE(2023, 2, 1), DATE(2023, 2, 1), IF([Start Date]@row > DATE(2023, 2, 28), "", [Start Date]@row)), DATE(2023, 2, 28)) * [Allocation %]@row * 8, "No Feb 2023 Work Days")
-
Thanks, Mike. Right now, that formula works when placed in a row that has February dates. But when placed in a cell without February dates falling between the "Start Date" and "End Date", I'm getting the same total (where hopefully, I'd get the "No Feb 2023 Work Days" answer).
When Start Date is 01/30/2023 and End Date is 03/31/2023 and Allocation % is 70%, I'm getting the correct 112 hours for February.
But, on a different row, the Start Date is 09/26/2022 and End Date is 01/27/2023 (therefore zero February working days) and Allocation % is 70%, I'm still getting the 112 hours for February, but I think I should be getting "No Feb 2023 Work Days".
-
You're welcome. It looked to work for me when I changed dates around. Now that I think of it though, I didn't add something to account for the End Date if it were say 02/23/2023 or something. That could be added in to the formula though without too much effort.
I believe this might account for that solution:
=IFERROR(NETWORKDAYS(IF([Start Date]@row < DATE(2023, 2, 1), DATE(2023, 2, 1), IF([Start Date]@row > DATE(2023, 2, 28), "", [Start Date]@row)), IF([End Date]@row < DATE(2023, 2, 28), [End Date]@row, DATE(2023, 2, 28))) * [Allocation %]@row * 8, "No Feb 2023 Work Days")
-
Mike, we're super close. Thank you. I think it's not accounting for start and end dates that are outside of February 2023 (or perhaps even further in the past). For instance, I'm getting an answer of -22.4 when the start and end dates are 09/26/2022 and 01/27/2023.
-
Try this:
=IFERROR(NETWORKDAYS(IF([Start Date]@row < DATE(2023, 2, 1), DATE(2023, 2, 1), IF([Start Date]@row > DATE(2023, 2, 28), "", [Start Date]@row)), IF([End Date]@row < DATE(2023, 2, 1), "", IF([End Date]@row < DATE(2023, 2, 28), [End Date]@row, DATE(2023, 2, 28)))) * [Allocation %]@row * 8, "No Feb 2023 Work Days")
-
Bingo. Many, many thanks Mike.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63K Get Help
- 380 Global Discussions
- 212 Industry Talk
- 442 Announcements
- 4.6K Ideas & Feature Requests
- 140 Brandfolder
- 129 Just for fun
- 130 Community Job Board
- 449 Show & Tell
- 30 Member Spotlight
- 1 SmartStories
- 305 Events
- 34 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!