This tutorial would explain various ways of COUNTIF function in LibreOffice Calc which can be used to count strings, numbers from a cell, range, rows, columns etc.
COUNTIF Function – Syntax
COUNTIFS(Range1; Criterion1 [; Range2; Criterion2 [; ...]])
Returns the count of rows or columns that meet the criteria.
With Number in Formula
Below example returns the count of 20 in the range A1:A7. In this below example, number 20 is present twice in the range. Thus the result is 2.
With Number as Cell Reference
You can also specify 20 as a cell reference. The result would be similar. COUNTIF would try to count the value specified in cell D1.
Count Numbers with Operators
COUNTIF also can count using logical operators. It can count number of rows, columns which satisfy the greater than, less than conditions.
In above example, if we need to count number of rows having values greater than 20, use below formula. Note that the greater than operator should be used as a string (i.e. use double quotes).
Without cell reference you can use COUNTIF(A1:A7,”>20″) as well which would give same result.
Use “<” sign to find out number of rows less than the specified value.
Not Equal To
Similarly use “<>” sign to find out number of rows not equal to the specified value.
Equal, Greater Than Equal, Less Than Equal
You can use “=”, “>=” and “<=” in the above formulas to get the results for Equal, Greater Than Equal and Less Than Equal to a specified value.
COUNTIF Using OR
You can also combine two COUNTIF functions to achieve more. Below example returns the count of rows which is having 20 or 10.
Using another function inside COUNTIF
It is possible to use another Calc function in the criteria of COUNTIF. Following example returns the values greater than the average of A1:A7 i.e. 32.7
Count String or Text
COUNTIF can be used to count any text, string as well in Calc cells like the numbers. The formula is exactly the same. Only the criteria should be a text/string specified by double quotes.
Count a specific text
The following example counts the text “apple” in the range A1:A10.
Count all text
The above example A1:A10 is having mix of values – numbers and texts. If you want to count the rows having texts only, below formula can be used.
* gives the count of all the cells including numeric and text. COUNT() function gives the count of only numeric cells.
a) To count all the cells with text start with any text (e.g. “apple”), use criteria as below
b) To count all the cells with text containing any matching string (e.g. “apple”), use below criteria
c) To count the cells with matching string with any one character at the end, use below criteria
So, this is how you can use COUNTIF for various usage in LibreOffice Calc.
Drop a comment below, if you have any questions, feedback on this tutorial. Don’t forget to subscribe, follow using social links for more updates.