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
- Customer Resources
- 64.8K Get Help
- 437 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!