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

  • Jeff Reisman
    Jeff Reisman ✭✭✭✭✭✭
    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

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!