Nested IF / AND Statements
I'm trying to put together formulas that will allow me to report forecasted labor across the months a project is active. I have all the formulas working individually but can't figure out how to group them into a singular formula. For example:
- Project Start: 6/17/24
- Project End: 8/21/24
- Forecast Cost: $10,000
The way I think this should work is that four date formulas need to be accounted for:
- Work starts and ends in the same month = full forecasted amount
- =IF(AND(MONTH(Start@row) = 6, MONTH(END@row) = 6), [Forecast Cost]@row, "")
- Work starts for the specified month but does not finish in the same month = calculate the number of days in the starting month and multiply by the daily cost
- =IF(AND(MONTH(Start@row) = 6, MONTH(End@row) > 6), StartMoDays@row * DailyCost@row, "")
- Work doesn't start or end in the specified month = monthly forecast cost
- =IF(AND(MONTH(Start@row) < 6, MONTH(End@row) > 6), DailyCost@row * 30, "")
- Work ends in that month = number of days in the end month multiplied by the daily cost
- =IF(AND(MONTH(Start@row) < 6, MONTH(End@row) = 6), EndMoDays@row * DailyCost@row, "")
This is how I've tried to assemble the relevant formulas:
=IF(AND(MONTH(Start@row) = 6, MONTH(END@row) = 6), [Forecast Cost]@row, ""), IF(AND(MONTH(Start@row) = 6, MONTH(End@row) > 6), StartMoDays@row * DailyCost@row, ""), IF(AND(MONTH(Start@row) < 6, MONTH(End@row) > 6), DailyCost@row * 30, ""), IF(AND(MONTH(Start@row) < 6, MONTH(End@row) = 6), EndMoDays@row * DailyCost@row, "")
NOTE: I do adjust the formula months based on the month they are entered in.
Answers
-
It looks like you're closing your arguments so it can't work through the list. Try it like this:
=IF(AND(MONTH(Start@row) = 6, MONTH(END@row) = 6), [Forecast Cost]@row, IF(AND(MONTH(Start@row) = 6, MONTH(End@row) > 6), StartMoDays@row * DailyCost@row, IF(AND(MONTH(Start@row) < 6, MONTH(End@row) > 6), DailyCost@row * 30, IF(AND(MONTH(Start@row) < 6, MONTH(End@row) = 6), EndMoDays@row * DailyCost@row, "")
-
Thank you so much that worked!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.1K Get Help
- 414 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 141 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!