Assistance with a calculation that compares the current date to month/year
I am calculating labor costs based on project duration. I need to know the labor dollars only for the months greater than the current month (for example, if this month is July/2020, then only calculate August/2020 through February/2021. The following formula sums hours x rate based on value in month columns 1 - xx. What I have below works for the month of July/2020, but it is producing a negative number because I am subtracting the value of a calculated column [Total Labor Forecast]25 at the end. I have tried to move [Total Labor Forecast]25 immediately following SUM, but it doesn't work. I'm sure this is a syntax issue, but I have not been successful in resolving it. Any assistance or guidance is greatly appreciated! Thank you.
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020), SUM([Month 1]25 * [Month 1]2) * Rate25) - [Total Labor Forecast]25
Best Answers
-
Genevieve P. Employee Admin
Hi Cheryl,
I believe you're running into an issue because in yourSUM functionyou are using a * symbol which willmultiplythe cells in row 25 and in row 2 together.
Are you wanting to add together the values from the range of rows 2 down to 25, instead? If so, you'll want to put colon between the two cells to indicate that it's a range, like this -
SUM([Month 1]2:[Month 1]25)
Our Help Center has more information on referencing columns (see here).
Try this as your full formula, instead:
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020), SUM([Month 1]2:[Month 1]25) * Rate25) - [Total Labor Forecast]25
Let me know if this works for you!
Cheers,
Genevieve
-
Genevieve P. Employee Admin
Hi Cheryl,
Thank you for clarifying! The SUM function will add the cells together instead of multiply, so in this instance you can use parenthesis to indicate what should be done... try this:
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020), (([Month 1]2 * [Month 1]25) * Rate25) - [Total Labor Forecast]25
Answers
-
Genevieve P. Employee Admin
Hi Cheryl,
I believe you're running into an issue because in yourSUM functionyou are using a * symbol which willmultiplythe cells in row 25 and in row 2 together.
Are you wanting to add together the values from the range of rows 2 down to 25, instead? If so, you'll want to put colon between the two cells to indicate that it's a range, like this -
SUM([Month 1]2:[Month 1]25)
Our Help Center has more information on referencing columns (see here).
Try this as your full formula, instead:
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020), SUM([Month 1]2:[Month 1]25) * Rate25) - [Total Labor Forecast]25
Let me know if this works for you!
Cheers,
Genevieve
-
Thank you, Genevieve, for looking at this for me. I am intending to multiply the cells in rows 25 and 2 together in this instance. I think I am close to resolving my problem by taking another direction, but appreciate your response to me.
-
Genevieve P. Employee Admin
Hi Cheryl,
Thank you for clarifying! The SUM function will add the cells together instead of multiply, so in this instance you can use parenthesis to indicate what should be done... try this:
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020), (([Month 1]2 * [Month 1]25) * Rate25) - [Total Labor Forecast]25
-
Thank you for your assistance, Genevieve. Much appreciated.
-
Hi Genevieve,
If you don't mind providing some additional direction, I have another question. I have a "Total Labor Forecast" column and a "Remaining Forecast" column. I have the following formula in the "Remaining Forecast" column, which is date driven based on TODAY()). Where the month/year is 07/20 and "Month 1" is "07/20", SUM [Total Labor Forecast], if TODAY is 08/20 and "Month 1" is 07/20, SUM [Total Labor Forecast] - [M1]. What I am trying to do is to reduce the amount in the "Remaining Forecast" calculation by the amount in the "M" columns for each month that is less than TODAY()). I need to perform this calculation for 42 months x 42 dates. As you can see, the "Month" columns are text and do not represent actual dates.
Is there a better way to perform this calculation?
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"), SUM(([Total Labor Forecast]6), IF(AND(MONTH(TODAY()) = 8, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"), SUM(([Total Labor Forecast]6 - [M1]6), IF(AND(MONTH(TODAY()) = 9, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"), SUM(([Total Labor Forecast]6 - [M1]6) - [M2]6), IF(AND(MONTH(TODAY()) = 10, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"), SUM(([Total Labor Forecast]6 - [M1]6 - [M2]6 - [M3]6), IF(AND(MONTH(TODAY()) = 11, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"), SUM(([Total Labor Forecast]6 - [M1]6 - [M2]6 - [M3]6) - [M4]6)
-
Genevieve P. Employee Admin
Hi Cheryl,
No problem at all, I'm happy to help!
Based on this, I'm assuming you want this formula in each row, in the "Remaining Forecast" column, with the grey cell at the top being a total of what's below. Now, in your formula you only state one number to SUM, the [Total Labor Forecast] in row 6... but there's nothing to SUM it with. SUM indicates there are values toadd together.
因此,您可以使用求和函数添加衣服ether the cells that need to be subtracted off of the Total, but you don't need it to reference that first cell.
Here's an example of what the first IF statement would look like if you pasted this into row 6, the yellow highlighted cell:
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row
You'll notice I didn't need the SUM function at all, since I'm just returning the one value from that row. So then lets look at the second statement:
IF(AND(MONTH(TODAY()) = 8, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row - [M1]@row,
Once again, there is no SUM function needed, as you are simply subtracting one value from another. Then we get into more than one cell needing to be subtracted, and here is where we can use SUM:
IF(AND(MONTH(TODAY()) = 9, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row - SUM([M1]@row, [M2]@row),
This will SUM together, or ADD together the values in M1 & M2 in that row, to minus off the total.
Here's what the full formula would be:
=IF(AND(MONTH(TODAY()) = 7, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row,IF(AND(MONTH(TODAY()) = 8, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row - [M1]@row,IF(AND(MONTH(TODAY()) = 9, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row - SUM([M1]@row, [M2]@row), IF(AND(MONTH(TODAY()) = 10, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row - SUM([M1]@row, [M2]@row, [M3]@row), IF(AND(MONTH(TODAY()) = 11, YEAR(TODAY()) = 2020, [Month 1]1 = "07/20"),[Total Labor Forecast]@row - SUM([M1]@row, [M2]@row, [M3]@row, [M4]@row))))))
Finally, you'll see I used @row instead of sayingrow 6. This will help your formula know it only needs to look to the values in that specific row. You can then drag-fill this down that entire "Remaining Forecast" column and it will update for each individual row!
Let me know if this works for you or if you have any more questions about nested IFs or theSUM function.
Cheers,
Genevieve
-
Hi Genevieve,
Thank you for the explanation above, and the approach to helping me understand the @row function. In my case, I need to extend the formula for 42 months, then the formula starts over with TODAY = 8/20 in M1, 9/20 in M1, 10/20 in M1, etc., and I think that I am hitting a character cell limit. Is there a way to build some sort of table on another sheet that the formula can reference? I am going to attempt to do that, just not certain what that will look like. I will give it a go and let you know what I come up with.
Thank you,
Cheryl
Help Article Resources
Categories
Check out theFormula Handbook template!
Instead of applying the formula to \"Multiselect Text String\" row, did you tried with \"Multiselect Values\" row?<\/p>
=IF(HAS([Multiselect Values]@row, [Component ID]@row), \"MATCH\", \"NO MATCH\")<\/p>
Thank you,<\/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":109493,"type":"question","name":"I am having trouble using \"And\", \"OR\" & \"Countif(s)\" to build a formula.","excerpt":"Hello, I am attempting to come up with a sheet summary formula that counts cells if they meet at least one of 3 different statuses in the same column, AND also meet one of 5 different statuses in a separate column. So using the screenshot I've provided as an example (although it doesn't have 5 different statuses in the…","snippet":"Hello, I am attempting to come up with a sheet summary formula that counts cells if they meet at least one of 3 different statuses in the same column, AND also meet one of 5…","categoryID":322,"dateInserted":"2023-08-25T20:03:21+00:00","dateUpdated":null,"dateLastComment":"2023-08-26T00:34:49+00:00","insertUserID":165710,"insertUser":{"userID":165710,"name":"SmarsheetNewb","url":"https:\/\/community.smartsheet.com\/profile\/SmarsheetNewb","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-26T00:33:27+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":161714,"lastUser":{"userID":161714,"name":"Carson Penticuff","url":"https:\/\/community.smartsheet.com\/profile\/Carson%20Penticuff","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/B0Q390EZX8XK\/nBGT0U1689CN6.jpg","dateLastActive":"2023-08-27T02:16:35+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":23,"score":null,"hot":3386005690,"url":"https:\/\/community.smartsheet.com\/discussion\/109493\/i-am-having-trouble-using-and-or-countif-s-to-build-a-formula","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109493\/i-am-having-trouble-using-and-or-countif-s-to-build-a-formula","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":109493,"commentID":392692,"name":"Re: I am having trouble using \"And\", \"OR\" & \"Countif(s)\" to build a formula.","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392692#Comment_392692","dateInserted":"2023-08-26T00:34:49+00:00","insertUserID":161714,"insertUser":{"userID":161714,"name":"Carson Penticuff","url":"https:\/\/community.smartsheet.com\/profile\/Carson%20Penticuff","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/B0Q390EZX8XK\/nBGT0U1689CN6.jpg","dateLastActive":"2023-08-27T02:16:35+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-26T00:33:25+00:00","dateAnswered":"2023-08-25T20:44:12+00:00","acceptedAnswers":[{"commentID":392662,"body":"
Try this:<\/p>
=COUNTIFS([Item Number]:[Item Number], OR(@cell = \"C001\", @cell = \"COO2\", @cell = \"COO3\", @cell = \"COO4\"), [Status]:[Status], OR(@cell = \"Green\", @cell = \"Yellow\", @cell = \"Red\"))<\/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":[{"tagID":254,"urlcode":"formulas","name":"Formulas"}]},{"discussionID":109474,"type":"question","name":"Help with date calculation formula","excerpt":"Hello, I'm trying to find a formula that will help me calculate how long an intake took to resolve. The rows I need to be calculated are Date Reported & Resolution Date. If the resolution date is blank I want it to use the current date in the calculation to see how long this issue has gone unresolved. Any help is much…","snippet":"Hello, I'm trying to find a formula that will help me calculate how long an intake took to resolve. The rows I need to be calculated are Date Reported & Resolution Date. If the…","categoryID":322,"dateInserted":"2023-08-25T16:29:39+00:00","dateUpdated":"2023-08-25T16:29:59+00:00","dateLastComment":"2023-08-25T23:01:30+00:00","insertUserID":165688,"insertUser":{"userID":165688,"name":"Nwest","title":"Systems Analyst","url":"https:\/\/community.smartsheet.com\/profile\/Nwest","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!ukHVZ18ImX4!BcjWAe8S9SY!l7iQo_PZHOx","dateLastActive":"2023-08-25T17:22:30+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":165688,"lastUserID":8888,"lastUser":{"userID":8888,"name":"Andrée Starå","title":"Smartsheet Expert Consultant & Partner | Workflow Consultant \/ CEO @ WORK BOLD","url":"https:\/\/community.smartsheet.com\/profile\/Andr%C3%A9e%20Star%C3%A5","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/0PAU3GBYQLBT\/nXWM7QXGD6464.jpg","dateLastActive":"2023-08-26T17:06:33+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":23,"score":null,"hot":3385987269,"url":"https:\/\/community.smartsheet.com\/discussion\/109474\/help-with-date-calculation-formula","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109474\/help-with-date-calculation-formula","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":109474,"commentID":392687,"name":"Re: Help with date calculation formula","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392687#Comment_392687","dateInserted":"2023-08-25T23:01:30+00:00","insertUserID":8888,"insertUser":{"userID":8888,"name":"Andrée Starå","title":"Smartsheet Expert Consultant & Partner | Workflow Consultant \/ CEO @ WORK BOLD","url":"https:\/\/community.smartsheet.com\/profile\/Andr%C3%A9e%20Star%C3%A5","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/0PAU3GBYQLBT\/nXWM7QXGD6464.jpg","dateLastActive":"2023-08-26T17:06:33+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-25T17:04:22+00:00","dateAnswered":"2023-08-25T16:36:59+00:00","acceptedAnswers":[{"commentID":392622,"body":"