Search code examples
google-sheetserror-handlingcountgoogle-sheets-formulagoogle-query-language

COUNTA returning 1 when expect 0, even when IFNA is used


I have a function in Sheets that is a QUERY wrapped in COUNTA to get the total number of values Column E dependent on a specific value in that same column, as well as a specific value in Column I. It works when the result isn't 0. If it's 0 I get a 1. I realize this is because it's counting the N/A as a value, but my efforts to resolve using IFERROR or IFNA are failing.

  • This formula works and returns #N/A

    =QUERY(Data!A2:I,"SELECT E WHERE E = 'FRIT' AND I = '0001'")

  • This formula works and returns 1 because it's counting the #N/A

    =IFNA(QUERY(Data!A2:I,"SELECT E WHERE E = 'FRIT' AND I = '0001'"),"0")

  • I was expecting this formula to work and return 0, but it still returns 1

    =COUNTA(IFNA(QUERY(Data!A2:I,"SELECT E WHERE E = 'FRIT' AND I = '0001'"),"0"))

Any advice on what I'm missing here? Are there limits on how many functions can be wrapped up? That's the only thing that I thought of that I can't find an answer on. Thanks for your help!


Solution

  • I was expecting this formula to work and return 0, but it still returns 1

    well, 0 (zero) is 1 (one) value...

    use:

    =COUNTA(IFNA(QUERY(Data!A2:I,"SELECT E WHERE E = 'FRIT' AND I = '0001'")))