Looking to capture the week# within a month
I am needing to identify a specific week# within the month, for instance 10/16/2023 (US) would be the 3rd week of October. It would need to be based on the Monday of the week, so if the day was 11/1/2023, Wednesday then I would think I need the week to be 5th week of October.
Or does anyone have a different viewpoint?
paul e. reeves
Principal Business Analyst
HMH
Best Answer
-
There is likely an easier (or at least shorter) way to do this, but this seems to work. The source date would be in [Day]
=IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 28)) = MONTH([Day]@row), "5", IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 21)) = MONTH([Day]@row), "4", IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 14)) = MONTH([Day]@row), "3", IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 7)) = MONTH([Day]@row), "2", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH([Day]@row), "1", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 28)), "5", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 21)), "4", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 14)), "3"))))))))
Answers
-
How would you prefer to define the week number? For example, November 6th is the first Monday of the month, but could be considered the second week, depending on how you approach it.
-
In your example, November 6th, I am leaning towards basing it on the Mondays..
paul e. reeves
Principal Business Analyst
HMH
-
There is likely an easier (or at least shorter) way to do this, but this seems to work. The source date would be in [Day]
=IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 28)) = MONTH([Day]@row), "5", IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 21)) = MONTH([Day]@row), "4", IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 14)) = MONTH([Day]@row), "3", IF(MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 7)) = MONTH([Day]@row), "2", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH([Day]@row), "1", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 28)), "5", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 21)), "4", IF(MONTH(IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2)) = MONTH((IF(WEEKDAY([Day]@row) = 1, [Day]@row - 6, [Day]@row - WEEKDAY([Day]@row) + 2) - 14)), "3"))))))))
-
Carson,
Thank you very much. I will definitely try this out. Another approach I have thought about since I asked this question would be the Week of MM/DD, Monday to Friday. At this point I am thinking it being a series of IF statements to test the weekday and subtract to Monday (2).
paul e. reeves
Principal Business Analyst
HMH
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 139 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!