How to skip "Blank" cell when calling "MONTH(@cell)" ?
In my sheet, there is a column called "Date" and the format is "Date". I want to count the number of all lines which are in a given month, like "Nov 2021" by calling:
=COUNTIF(Date:Date, MONTH(@cell)=11)
Cuz there are some Blank cell in the column, so it showed "Invalid Data Type".
How to fix it, any workaround?
Thanks.
Best Answer
-
It's pretty unintuitive, but you need an IFERROR inside the formula for it to ignore the blanks:
=COUNTIF(Date:Date, IFERROR(MONTH(@cell), 0) =11)
The IFERROR basically says if there's an error when finding the month from the date (in that there's no date value to get it from,) just assume the value is 0.
MONTH Function | Smartsheet Learning Center
By wrapping the MONTH function in an IFERROR function, the function will no longer produce an error.
This formula counts the number of values in the Date column that are equal to 11 (November).
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
Answers
-
It's pretty unintuitive, but you need an IFERROR inside the formula for it to ignore the blanks:
=COUNTIF(Date:Date, IFERROR(MONTH(@cell), 0) =11)
The IFERROR basically says if there's an error when finding the month from the date (in that there's no date value to get it from,) just assume the value is 0.
MONTH Function | Smartsheet Learning Center
By wrapping the MONTH function in an IFERROR function, the function will no longer produce an error.
This formula counts the number of values in the Date column that are equal to 11 (November).
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
-
Jeff, thanks for the great solution, works perfect! Thank you very much.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 434 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 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!