Is it possilble to use a calculated row reference in a formula?
I have a table (2x12) of data (sales $) for each month (one row per month) in the Current Year(CY) and Previous Year (PY) columns. I'm trying to calculate the YTD sales (by month) of CY and PY based on today's date using the function, Today().
I know I can use a formula like PY-YTD = SUM(PY1:PY4) to sum the first four rows (Jan-Apr) on the PY sales. This works for the month of May. Upon entering the month of June, 'PY4' will need to be updated to 'PY5'.
I know I can calculate the needed row by using MON(TODAY())-1. e.g. on May 4th, MON(TODAY())-1=4; on Jun 1, MON(TODAY())-1 = 5. Is there a way I can use 'MON(TODAY())-1' in a formula like this: SUM(PY1:PY'MON(TODAY()-1') to enable the calculation to use the correct row number without the need to update each month?
Thank you, John
Best Answer
-
Try this in your CY running total cell: =SUMIF(Month:Month, <MONTH(TODAY()), CY:CY)
And this in your PY running total cell: =SUMIF(Month:Month, <MONTH(TODAY()), PY:PY)
Both of these will basically sum any fields (either in CY or PY, depending on the formula) that are associated with a month number that is smaller than the current month.
If you want to include the current month's totals in the running totals, you'll simply change < to <=.
Let me know if it works for you!
Best,
Heather
Answers
-
Try this in your CY running total cell: =SUMIF(Month:Month, <MONTH(TODAY()), CY:CY)
And this in your PY running total cell: =SUMIF(Month:Month, <MONTH(TODAY()), PY:PY)
Both of these will basically sum any fields (either in CY or PY, depending on the formula) that are associated with a month number that is smaller than the current month.
If you want to include the current month's totals in the running totals, you'll simply change < to <=.
Let me know if it works for you!
Best,
Heather
-
Perfect!! THANKS!! 😃
-
Happy to help! 😊
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!