For Google Sheets, I've seen people use both =COUNTIF(range,"<>"&"")
as well as =COUNTIF(range,"<>")
to count the number of non-empty cells in a range.
Is there any difference, benefit, or concern, using one approach over the other?
For Google Sheets, I've seen people use both =COUNTIF(range,"<>"&"")
as well as =COUNTIF(range,"<>")
to count the number of non-empty cells in a range.
Is there any difference, benefit, or concern, using one approach over the other?
No difference. &""
is redundant.
The formulas ="<>"&""
and ="<>"
both return <>
.
This is necessarily so because any text string, whether "<>"
or "webAppsRocks"
, is equivalent to the result of joining nothing else to it.
"<>"&""
instead of "<>"
&""
in any of the following:
=COUNTIF(range,"<>&"")
=COUNTIF(range,"<>&""&"")
=COUNTIF(range,"<>"&""&""&""&""&""&""&""&""&""&"")
""
may reflect a lack of experience on the part of users possibly combined with a spillover effect from Microsoft Excel. Even though &""
is redundant in Excel as well, users habitually include empty strings ""
in formulas to avoid returning zero values. For example:# Excel Formula Examples
=IF(TRUE,) =IF(TRUE,"",) =0 =[ empty_string ]
=IFERROR(1/0,) =IFERROR(1/0,"") =0 =[ empty_string ]
If your goal is to count the number of values in a range or array, COUNTA is designed specifically to do that.
=COUNTA(range) vs. =COUNTIF(range,"<>")