Removal of #INVALID DATA TYPE
I have created the following formula which auto populates a cell with a date that is 3 years before the date in another field [Date Field]:
=DATE(YEAR([Date Field]@row) - 3, MONTH([Date Field]@row), DAY([Date Field]@row))
However, when there is no date in the source [Date Field] the return message is #INVALID DATA TYPE. Does anyone know how to replace this text with new text such as "No Launch Date" or "N/A" or "0" or even better leave as blank?
Many thanks
Best Answer
-
For this you would need a second IFERROR.
=IFERROR(IFERROR(DATE(.....), DATE(.....)), "")
Answers
-
You would wrap it in an IFERROR function.
=IFERROR(original_formula, "")
-
Thanks Paul. The original formula was as follows:
=DATE(YEAR([Local Regulatory Authorization Date (Best Case)]@row) - 3, MONTH([Local Regulatory Authorization Date (Best Case)]@row), DAY([Local Regulatory Authorization Date (Best Case)]@row))
At which point does the =IFERROR(original_formula, "") element go?
-
You would drop the entire thing (excluding the very first "=") into the spot where it says "original_formula".
-
Thanks Paul. I have tried that but unless I am not understanding it doesn't work. The original formula is as follows:
=DATE(YEAR([Local Regulatory Authorization Date (Best Case)]@row) - 2, MONTH([Local Regulatory Authorization Date (Best Case)]@row), DAY([Local Regulatory Authorization Date (Best Case)]@row))
By dropping this into the spot where you reference "original formula" it looks like this:
IFERROR(DATE(YEAR([Local Regulatory Authorization Date (Best Case)]@row) - 2, MONTH([Local Regulatory Authorization Date (Best Case)]@row), DAY([Local Regulatory Authorization Date (Best Case)]@row,"")))
Where there is no date on the source column [Local Regulatory Authorization Date (Best Case)] it still come sup with #INVALID DATA TYPE. Is this because the column Properties are formatted as a Date Type?
Really appreciate your feedback here Paul.
Kind regards
Mike
-
You have misplaced parenthesis. All of the closing parenthesis and everything from the original formula should go in the first portion of the IFERROR. As you have it, you are including that final comma quote quote inside of the final DAY function.
-
I really do not get this at all. You mention first portion of the IFERROR but in the original message you said =IFERROR(original_formula, "") which is the first part?
The original formula is =DATE(YEAR([Local Regulatory Authorization Date (Best Case)]@row) - 3, MONTH([Local Regulatory Authorization Date (Best Case)]@row), DAY([Local Regulatory Authorization Date (Best Case)]@row))
So if it reads =IFERROR(DATE(YEAR([Local Regulatory Authorization Date (Best Case)]@row) - 3, MONTH([Local Regulatory Authorization Date (Best Case)]@row), DAY([Local Regulatory Authorization Date (Best Case)]@row)) where does the , "" go if it starts =IFERRORDATE(YEAR([Local Regulatory Authorization Date (Best Case)]@row) ........etc
Sorry to be thick here but I just dont get it?
Thanks for your help and patience.
-
The first portion is "orignial_formula".
=IFERROR(DATE(.....), "")
If you look at the IFERROR function, there are two parts to it (aside from the actual function text itself).
You have the portion that determines what you want to evaluate. If there is no error, it outputs whatever is in that first portion. Next you have a comma, then you have the second portion of the IFERROR that determines what is output when the first portion throws an error. Double quotes with nothing in between is a blank.
-
Thanks Paul. I know now why I wasn't getting any joy. It was because of was trying to calculate where there were months and not years. I can sort where there are round years, i.e. 12 months, 24 months, etc but where there are 9 months for example your original solution was as follows:
=IFERROR(DATE(YEAR([First Commercial Sales Date (Best Case)]@row), MONTH([First Commercial Sales Date (Best Case)]@row) - 9, DAY([First Commercial Sales Date (Best Case)]@row)), DATE(YEAR([First Commercial Sales Date (Best Case)]@row) - 1, MONTH([First Commercial Sales Date (Best Case)]@row) + 3, DAY([First Commercial Sales Date (Best Case)]@row)))
For this, it looks like it is using the IFERROR for last element but not sure where the ,"" would go where there is no date at all?
-
For this you would need a second IFERROR.
=IFERROR(IFERROR(DATE(.....), DATE(.....)), "")
-
Paul, you are a star !!! Thanks so much for your help and patience. It is really appreciated.
Regards
Mike
-
Happy to help. 👍️
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 439 Global Discussions
- 138 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 67 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!