2

I need to count how many "Yes" or "N/A" values there are in a particular column on a sheet, so I have a formula like this:

=Rows(Query(INDIRECT('SheetName'!A:H"), "SELECT * WHERE (Col3=""Yes"" OR Col3 = ""N/A"")",""))

But when the WHERE clause filters out every row I get an error "error: Query completed with an empty output."

When the query's output is empty I'd hope to get a 0 for the "row count". Is there an easy way to do this?

2 Answers 2

3

The easiest way might be to wrap the entire formula in =IFERROR(...;0).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks... no idea why I didn't get notified of your answer. As it turns out that's the exact solution I came to a few days later.
Is there a succinct way to prevent the "#NA" error, and not rescue all other types of errors? You could use IF and ISNA, but then you would have to copy the entire formula if I'm not mistaken.
0

The way you're doing it is very roundabout, especially when there is a built-in function for counting the number of matching cells in a column or row: COUNTIF. Also, if you happened to move your source sheet around, your QUERY may stop giving you the correct result. Try this, assuming column C is the one you're after to count how many occurrences of "N/A" and "Yes" appear.

=COUNTIF(C:C,"N/A")+COUNTIF(C:C,"Yes")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.