IFERROR and january dates for previous month (and Year)
Happy New Year All.
I have successfully had help in navigating the problems of "Previus" month when a new year like now for both COUNTIFS and SUMIFS
However, I have a simple IF statement and just cannot get it to work.
4 fields
Date & Time - this is the automated date creation value
This Month - dropdown with True or False values calculated by formula
=IF(DATE(YEAR([Date & Time]@row), MONTH([Date & Time]@row), 1) = DATE(YEAR(TODAY()), MONTH(TODAY()), 1), "True", "False")
which still works OK (phew)
Last Month - dropdown with True or False values calculated by formula
=IF(DATE(YEAR([Date & Time]@row), MONTH([Date & Time]@row), 1) = DATE(YEAR(TODAY()), (MONTH(TODAY()) - 1), 1), "True", "False")
which of course goes wrong this month as need to remove 1 from year and set month = 12
Previous Month - dropdown with True or False values calculated by formula
=IF(DATE(YEAR([Date & Time]@row), MONTH([Date & Time]@row), 1) = DATE(YEAR(TODAY()), (MONTH(TODAY()) - 2), 1), "True", "False")
which of course goes wrong this month as need to remove 1 from year and set month = 12
Now I have tried adding in IFERROR statements but whatever I try comes back #UNPARSEABLE
=IF(DATE(YEAR([Date & Time]@row, MONTH([Date & Time]@row,1) = IFERROR(DATE(YEAR(TODAY()), MONTH(TODAY()) -1,1), DATE(YEAR(TODAY()) -1, 12, 1))), "True", False")
So I am stuck and really hope someone can help me as my brain just cannot push thrugh this one.
Many thanks in anticipation
Sue
Sue Rogers
AmerisourceBergen - MWI Animal Health
Business Analyst
Best Answer
-
Well it took a bit of reqording to explain what I wanted but AI seems to have fixed it a completely different way.
I have posted the results here for anyone lese who is interested
this month =
=IF(AND(MONTH([Date & Time]@row) = MONTH(TODAY()), YEAR([Date & Time]@row) = YEAR(TODAY())), "True", "False")last month =
=IF(OR(AND(MONTH([Date & Time]@row) = MONTH(TODAY()) - 1, YEAR([Date & Time]@row) = YEAR(TODAY())), AND(MONTH(TODAY()) = 1, MONTH([Date & Time]@row) = 12, YEAR([Date & Time]@row) = YEAR(TODAY()) - 1)), "True", "False")previous month =
=IF(OR(AND(MONTH([Date & Time]@row) = IF(MONTH(TODAY()) = 1, 11, IF(MONTH(TODAY()) = 2, 12, MONTH(TODAY()) - 2)), YEAR([Date & Time]@row) = IF(OR(MONTH(TODAY()) = 1, MONTH(TODAY()) = 2), YEAR(TODAY()) - 1, YEAR(TODAY()))), AND(MONTH([Date & Time]@row) = MONTH(TODAY()) - 2, YEAR([Date & Time]@row) = YEAR(TODAY()))), "True", "False")
Not sure my brain can unwrap what has been coded as so many brackets, ifs, ors, ands etc. but it seems to work for now. I'll wait to see if I have it correct for previous month in February
Happy new year all
Sue Rogers
AmerisourceBergen - MWI Animal Health
Business Analyst
Answers
-
Well it took a bit of reqording to explain what I wanted but AI seems to have fixed it a completely different way.
I have posted the results here for anyone lese who is interested
this month =
=IF(AND(MONTH([Date & Time]@row) = MONTH(TODAY()), YEAR([Date & Time]@row) = YEAR(TODAY())), "True", "False")last month =
=IF(OR(AND(MONTH([Date & Time]@row) = MONTH(TODAY()) - 1, YEAR([Date & Time]@row) = YEAR(TODAY())), AND(MONTH(TODAY()) = 1, MONTH([Date & Time]@row) = 12, YEAR([Date & Time]@row) = YEAR(TODAY()) - 1)), "True", "False")previous month =
=IF(OR(AND(MONTH([Date & Time]@row) = IF(MONTH(TODAY()) = 1, 11, IF(MONTH(TODAY()) = 2, 12, MONTH(TODAY()) - 2)), YEAR([Date & Time]@row) = IF(OR(MONTH(TODAY()) = 1, MONTH(TODAY()) = 2), YEAR(TODAY()) - 1, YEAR(TODAY()))), AND(MONTH([Date & Time]@row) = MONTH(TODAY()) - 2, YEAR([Date & Time]@row) = YEAR(TODAY()))), "True", "False")
Not sure my brain can unwrap what has been coded as so many brackets, ifs, ors, ands etc. but it seems to work for now. I'll wait to see if I have it correct for previous month in February
Happy new year all
Sue Rogers
AmerisourceBergen - MWI Animal Health
Business Analyst
-
Hey @SueinSpain,
Thank you for posting your solution. I'm glad you got this resolved!
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 69 Community Job Board
- 497 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!