Formula issue comparing dates
First, this community is GREAT, and has really helped me with understanding formulas, so I'm hoping someone can help with a frustrating error. I have a list of projects where I want to designate "Y" if active in current year. I have start and end date columns and I my formula works when I have both the start and the end date. The problem is, I have some projects without start dates and some without end dates (from a source I can't control). I tested out a formula that takes each scenario into account and each individual formula works, BUT when combined into 1 nested IF statement, I get an error. I'd like to have one column formula that will work no matter what the date situation is. I hope the picture below explains better. (I replicated the scenario in Excel, and one nested IF formula worked for all scenarios.)
Thanks in advance for any advice!
Best Answer
-
Val,
This may not be pretty but it's simple and you don't need to mess with a bunch of nested IFs. I would create two helper columns [Start Date Helper] [End Date Helper] (which can be hidden later and left alone once the column formulas are set).
Start Date Helper Formula: =IFERROR(YEAR(Start Date), YEAR(End Date))
End Date Helper Formula: =IFERROR(YEAR(End Date), YEAR(Start Date))
Result Formula: =IF(AND(Start Date Helper <= YEAR(TODAY()), End Date Helper >= YEAR(TODAY())), "Yes", "No")
Hidden columns so it looks clean:
Hope this helps!
Kev
Answers
-
Val,
This may not be pretty but it's simple and you don't need to mess with a bunch of nested IFs. I would create two helper columns [Start Date Helper] [End Date Helper] (which can be hidden later and left alone once the column formulas are set).
Start Date Helper Formula: =IFERROR(YEAR(Start Date), YEAR(End Date))
End Date Helper Formula: =IFERROR(YEAR(End Date), YEAR(Start Date))
Result Formula: =IF(AND(Start Date Helper <= YEAR(TODAY()), End Date Helper >= YEAR(TODAY())), "Yes", "No")
Hidden columns so it looks clean:
Hope this helps!
Kev
-
Kev,
Thank you SO much! Worked like a charm and solved my problem!
I did forget one scenario, I also have projects with no start OR end date, so I just added an IFERROR to the final formula:
=IFERROR(IF(AND([Start Date Helper]@row <= YEAR(TODAY()), [End Date Helper]@row >= YEAR(TODAY())), "Yes", ""), "Null").
You just made my day.
Cheers,
Val
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 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!