Help with Determining if date@row occurred last month using multiple criteria.
Hi. I'm looking for some help with a formula.
I'm using the following formula to identify if the date last touched occurred last month, which works perfectly, but it was not my formula (which is why I'm having problems)…
=IFERROR(IF(AND(MONTH(TODAY()) = 1, YEAR(TODAY()) - YEAR([Last Touched]@row) = 1, (MONTH(TODAY()) - MONTH([Last Touched]@row) = -11)), "Previous Month", IF(YEAR(TODAY()) = YEAR([Last Touched]@row), IF(MONTH(TODAY()) - MONTH([Last Touched]@row) = 1, "Previous Month", "-"), "-")), "-")
I'm trying to create an IF OR formula where if the date in the "Last Touched" column occurred last month OR if the date in the "RM Close Date" occurred last month, then answer "Previous Month"; otherwise, answer "_."
Since I don't understand the formula I'm starting with, I'm having trouble adding the OR statement. Can anyone help me?
Answers
-
I see what the formula is doing, but I would approach it a bit differently.
=IF(AND(MONTH([Last Touched]@row) = MONTH(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1), YEAR([Last Touched]@row) = YEAR(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1)), "Previous Month", "_")
We get the first of the current month and subtract one day from it to get the last day of the previous month. Then we can use a MONTH and YEAR function to get the month and year numbers for the previous month. If those match the month and year numbers from last touched, then we output "Previous Month".
Having it like this allows us to expand this to multiple columns by copying the full AND statement, adjusting the column name, and pasting it into an OR statement.
AND(MONTH([RM Close Date]@row) = MONTH(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1), YEAR([RM Close Date]@row) = YEAR(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1))
OR(AND(………………), AND(………………..))
-
I appreciate your recommendation to change the base formula. My question is this: When I try to mesh the IF(OR(AND formula together, I get an "incorrect argument" error. I went back to double-check my parentheses, but I need help finding my mistake. Do you see anything obvious?
=IF(OR(AND(MONTH([Last Touched]@row) = MONTH(DATE(YEAR(TODAY()), MONTH(TODAY()), 1)- 1), YEAR([Last Touched]@row) = YEAR(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1)), IF(OR(AND(MONTH([DM Close Date]@row) = MONTH(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1), YEAR([DM Close Date]@row) = YEAR(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1)))), "Previous Month", "_")
-
Give this a try:
=IF(OR(AND(MONTH([Last Touched]@row) = MONTH(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1), YEAR([Last Touched]@row) = YEAR(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1)), AND(MONTH([DM Closed Date]@row) = MONTH(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1), YEAR([DM Closed Date]@row) = YEAR(DATE(YEAR(TODAY()), MONTH(TODAY()), 1) - 1))), "Previous Month", "_")
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!