DCOUNTA counts the number of rows (records) in a database that match the specified search conditions, and contain numeric or alphanumeric values.
DCOUNTA(Database; [DatabaseField]; SearchCriteria)
Returns a non-negative integer value which is the count of rows in the Database that qualify the SearchCriteria in the given DatabaseField, and contain numeric or alphanumeric values.
Database is the cell range defining the database.
DatabaseField specifies the column where the function operates on after the search criteria of the first parameter is applied and the data rows are selected. It is not related to the search criteria itself. For the DatabaseField parameter you can enter a reference to a header cell or a number to specify the column within the Database area, starting with 1. To reference a column by means of the literal column header name, place quotation marks around the header name.
SearchCriteria is the cell range containing search criteria. If you write several criteria in one row they are connected by AND. If you write the criteria in different rows they are connected by OR. Empty cells in the search criteria range will be ignored.
- Choose Tools > Options > LibreOffice Calc > Calculate to define how LibreOffice Calc acts when searching for identical entries.
- See also the Wiki page about Conditional Counting and Summation.
- If the DatabaseField argument is omitted, DCOUNTA returns the count of all records that satisfy Criteria. For the DatabaseField parameter you can enter a reference to a header cell or a number to specify the column within the Database area, starting with 1. To reference a column by means of the literal column header name, place quotation marks around the header name.
The Database category may be confused with a database integrated in LibreOffice. However, there is no connection between a database in LibreOffice and the Database category in LibreOffice Calc.
The search supports wildcards or regular expressions. With regular expressions enabled, you can enter "all.*", for example to find the first location of "all" followed by any characters. If you want to search for a text that is also a regular expression, you must either precede every character with a "\" character, or enclose the text into \Q...\E. You can switch the automatic evaluation of wildcards or regular expression on and off in Tools > Options > LibreOffice Calc > Calculate.
The following data will be used in some of the function description examples:
The range A1:E10 lists the children invited to Joe's birthday party. The following information is given for each entry: column A shows the name, B the grade, then age in years, distance to school in meters and weight in kilograms.
|1||Name||Grade||Age||Distance to School||Weight|
|13||Name||Grade||Age||Distance to School||Weight|
|=DCOUNTA(A1:E10;D1;A13:E14)||count of rows of distance to school where distance to school is greater than 600 so we want to know how many children have to travel more than 600 meters to school. If the result is to be stored in cell B16. Set the cursor in cell B16. Enter the formula =DCOUNTA(A1:E10;D1;A13:E14) in B16. The Function Wizard helps you to input ranges. Database is the range of data to be evaluated, including its headers: in this case A1:E10. DatabaseField specifies the column for the search criteria: in this case, the column with the numerical distance values. SearchCriteria is the range where you can enter the search parameters: in this case, A13:E14.It will give the same result as DCOUNT for these arguments.||5|
|=DOCUNTA(A1:E10;"Name";A13:E14) where we delete the old search criteria and enter >=E under Name in field A14||search for the number of children whose name starts with an E or a subsequent letter||5|
|=DOCUNTA(A1:E10;"Name";A13:E14) where we delete the old search criteria and enter >=E under Name in field A14 and delete all number values for Greta in row 8||Search for the number of children whose name starts with an E or a subsequent letter. Row 8 is no longer included in the count because it does not contain any values. The name Greta is text, not a value. Note that the DatabaseField parameter must point to a column that can contain values.||4|
Related LibreOffice functions:
Equivalent Excel functions: