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
- Smartsheet Customer Resources
- 63K Get Help
- 380 Global Discussions
- 212 Industry Talk
- 442 Announcements
- 4.6K Ideas & Feature Requests
- 140 Brandfolder
- 129 Just for fun
- 130 Community Job Board
- 449 Show & Tell
- 30 Member Spotlight
- 1 SmartStories
- 305 Events
- 34 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!