Database Functions

From Apache OpenOffice Wiki
Jump to: navigation, search



Database Functions

This section deals with functions used with data organized as a single row of data for a single record. The Database category should not be confused with the Base database component in OpenOffice. A Calc database is simply a range of cells that comprises a block of related data, where each row contains a separate record. There is no connection between a database in OpenOffice Base and the Database category in OpenOffice Calc.

The database functions use the following common arguments:

  • Database is a range of cells that define the database.
  • Database_field specifies the column on which the function operates after the search criteria of the first parameter are applied and the data rows are selected. It is not related to the search criteria itself. The number 0 specifies the whole data range. To reference a column by using the column header name, place quotation marks around the header name.
  • Search_criteria is a cell range containing the search criteria. Empty cells in the search criteria range will be ignored.
Documentation note.png All the search-criteria arguments for the database functions support regular expressions. For example, “all.*" can be entered to find the first location of “all” followed by any characters. To search for text that is also a regular expression, precede every character with a \ character. You can switch the automatic evaluation of regular expressions on and off in Tools → Options → OpenOffice Calc → Calculate.

Table 43: Database functions

Syntax Description
DAVERAGE(database; database_field; search_criteria) Returns the average of the values of all cells (fields) in all rows (database records) that match the specified search_criteria. The search supports regular expressions.
DCOUNT(database; database_field; search_criteria) Counts the number of rows (records) in a database that match the specified search_criteria and contain numerical values. The search supports regular expressions. For the database_field parameter, enter a cell address to specify the column, or enter the number 0 for the entire database. The parameter cannot be empty.
DCOUNTA(database; database_field; search_criteria) Counts the number of rows (records) in a database that match the specified search_criteria and contain numeric or alphanumeric values. The search supports regular expressions.
DGET(database; database_field; search_criteria) Returns the contents of the referenced cell in a database that matches the specified search_criteria. In case of an error, the function returns either #VALUE! for no row found, or Err502 for more than one cell found.
DMAX(database; database_field; search_criteria) Returns the maximum content of a cell (field) in a database (all records) that matches the specified search_criteria. The search supports regular expressions.
DMIN(database; database_field; search_criteria) Returns the minimum content of a cell (field) in a database that matches the specified search_criteria. The search supports regular expressions.
DPRODUCT(database; database_field; search_criteria) Multiplies all cells of a data range where the cell contents match the search_criteria. The search supports regular expressions.
DSTDEV(database; database_field; search_criteria) Calculates the standard deviation of a population based on a sample, using the numbers in a database column that match the search_criteria. The records are treated as a sample of data.
DSTDEVP(database; database_field; search_criteria) Calculates the standard deviation of a population based on all cells of a data range which match the search_criteria. The records from the example are treated as the whole population.
DSUM(database; database_field; search_criteria) Returns the sum of all cells in a database field in all rows (records) that match the specified search_criteria. The search supports regular expressions.
DVAR(database; database_field; search_criteria) Returns the variance of all cells of a database field in all records that match the specified search_criteria. The records from the example are treated as a sample of data.
DVARP(database; database_field; search_criteria) Calculates the variance of all cell values in a database field in all records that match the specified search_criteria. The records are treated as an entire population.
Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools