Tartalom

# Adatbázis-függvények

### Áttekintés

The twelve functions in the Database category help you to analyze a simple database that occupies a rectangular spreadsheet area comprising columns and rows, with the data organized as one row for each record. The header cell of each column displays the name of the column and that name usually reflects the contents of each cell in that column.

The functions in the Database category take three arguments as follows:

1. Database. The cell range of the database.

2. DatabaseField. The column containing the data to be used in the function’s calculations.

3. SearchCriteria. The cell range of a separate area of the spreadsheet containing search criteria.

These arguments are described more fully below.

All functions have the same outline concept of operation. The first logical step is to use the specified SearchCriteria to identify the subset of records in the Database that are to be used during subsequent calculations. The second step is to extract the data values and perform the calculations associated with the specific function (average, sum, product, and so on). The values processed are those in the DatabaseField column of the selected records.

Calc treats dates and logical values (TRUE and FALSE) as numeric when calculating with these functions.

### Adatbázis-függvények argumentumai

The following argument definitions apply for all functions in the Database category:

1. Adatbázis-argumentum

   Database specifies the range of cells occupied by the database table. The first row of the range contains the field names, and subsequent rows are records with corresponding field values.

   One way of defining the range of cells is to enter the cell reference for the upper left-hand cell, followed by a colon (:), and then the lower right-hand cell reference. An example might be A1:E10.

   The Database argument may also be specified by passing the name of a named range or database range. Using a meaningful name to define the cell range can enhance formula readability and document maintenance. If the name does not match the name of a defined range, Calc reports a #NAME? error.

   Other errors that might be reported as a result of an invalid Database argument are #VALUE! and Err:504 (error in parameter list).

2. Adatbázismező-argumentum

   DatabaseField specifies the column which the function will use for its calculations after the search criteria have been applied and the data rows have been selected. It is not related to the search criteria.

   Specify the DatabaseField argument in any of the following ways:

   - By entering a reference to a header cell within the Database area. Alternatively, if the cell has been given a meaningful name as a named range or database range, enter that name. If the name does not match the name of a defined range, Calc reports a #NAME? error. If the name is valid but does not correspond to one cell only, Calc reports Err:504 (error in parameter list).

   - Egy szám megadásával az Adatbázis területen belüli oszlopot határozza meg, kezdve az 1-gyel. Például, ha egy Adatbázis a D6:H123 cellatartományt foglalja el, akkor írja be a 3-at az F6-os fejléccella jelölésére. A Calc olyan egész értéket vár, amely 1 és az Adatbázis-ban meghatározott oszlopok száma között van, és figyelmen kívül hagyja a tizedesvessző utáni számjegyeket. Ha az érték 1-nél kisebb, a Calc Err:504 (hiba a paraméterlistában) jelzést ad. Ha az érték nagyobb, mint az Adatbázis oszlopainak száma, a Calc #ÉRTÉK! hibát jelent.

   - By entering the literal column header name from the first row of the Database range, placing quotation marks around the header name. For example, “Distance to School”. If the string does not match one of the Database area’s column headings, Calc reports Err:504 (error in parameter list). You can also provide a reference to an arbitrary cell (not within the Database and SearchCriteria areas) that contains the required string.

   The DatabaseField argument is optional for the DCOUNT and DCOUNTA functions but it is required for the other ten Database functions.

3. Keresési_feltétel-argumentum

   SearchCriteria specifies the range of cells containing search criteria. Like Database, its first row is also field names, and subsequent rows are conditions for related fields. The Database and SearchCriteria areas need not be adjacent, or even on the same sheet.

   A reference to an empty cell is interpreted as the numeric value 0.

   A matching expression can be:

   - A number or logical value. A matching cell content equals the number or logical value.

   - A value beginning with a comparator (<, <=, =, >, >=, <>).

     For =, if the value is empty it matches empty cells.

     For <>, if the value is empty it matches non-empty cells.

     For <>, if the value is not empty it matches any cell content except the value, including empty cells.

     Note: "=0" does not match empty cells.

     For = and <>, if the value is not empty and can not be interpreted as a number type or one of its subtypes and the property Search criteria = and <> must apply to whole cells is checked, comparison is against the entire cell contents, if unchecked, comparison is against any subpart of the field that matches the criteria. For = and <>, if the value is not empty and can not be interpreted as a Number type or one of its subtypes applies.

   - Other Text value. If the property Search criteria = and <> must apply to whole cells is true, the comparison is against the entire cell contents, if false, comparison is against any subpart of the field that matches the criteria. The expression can contain text, numbers, regular expressions or wildcards (if enabled in calculation options).

   One way of defining the range of cells is to enter the cell reference for the upper left-hand cell, followed by a colon (:), and then the lower right-hand cell reference. For example, A13:B14. The cell range may also be specified by passing the name of a defined named range or database range. If the name does not match the name of a defined range, Calc reports a #NAME? error.

   Err:504 (error in parameter list) may also be reported as a result of an invalid SearchCriteria argument.

   The contents of the SearchCriteria area are described in more detail in the next section.

### Keresési feltétel meghatározása

The number of columns occupied by the SearchCriteria area need not be the same as the width of the Database area. All headings that appear in the first row of SearchCriteria must be identical to headings in the first row of Database. However, not all headings in Database need appear in the first row of SearchCriteria, while a heading in Database can appear multiple times in the first row of SearchCriteria.

Search criteria are entered into the cells of the second and subsequent rows of the SearchCriteria area, below the row containing headings. Blank cells within the SearchCriteria area are ignored.

Create criteria in the cells of the SearchCriteria area using the comparison operators <, <=, =, <>, >=, and >. = is assumed if a cell is not empty but does not start with a comparison operator.

If you write several criteria in one row, they are connected by AND. If you write several criteria in different rows, they are connected by OR.

Criteria can be created using wildcards, providing that wildcards have been enabled via the Enable wildcards in formulas option on the LibreOffice - Preferences Tools - Options - LibreOffice Calc - Calculate dialog. When interoperability with Microsoft Excel is important for your spreadsheet, this option should be enabled.

Even more powerful criteria can be created using regular expressions, providing that regular expressions have been enabled via the Enable regular expressions in formulas option on the LibreOffice - Preferences Tools - Options - LibreOffice Calc - Calculate dialog.

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".

Another setting that affects how the search criteria are handled is the Search criteria = and <> must apply to whole cells option on the LibreOffice - Preferences Tools - Options - LibreOffice Calc - Calculate dialog. This option controls whether the search criteria you set for the Database functions must match the whole cell exactly. When interoperability with Microsoft Excel is important for your spreadsheet, this option should be enabled.

### Examples of Database Function Use

The following table provides an example database table that is utilized to demonstrate how to use the functions in the Database category. The cell range A1:E10 contains fictitious information about the guests invited to Joe's birthday party. The following information is given for each guest - name, school grade, age in years, distance to school in meters, and weight in kilograms.

| A | B | C | D | E
1 | Név | Osztály | Kor | Távolság | Tömeg
2 | András | 3 | 9 | 150 | 40
3 | Bettina | 4 | 10 | 1000 | 42
4 | Károly | 3 | 10 | 300 | 51
5 | Dániel | 5 | 11 | 1200 | 48
6 | Éva | 2 | 8 | 650 | 33
7 | Ferenc | 2 | 7 | 300 | 42
8 | Gréta | 1 | 7 | 200 | 36
9 | Henrik | 3 | 9 | 1200 | 44
10 | Irén | 2 | 8 | 1000 | 42
11 |  |  |  |  |

The following six examples use the database table above, combined with different search criteria areas.

#### 1. példa

| A | B | C | D | E
12 | Név | Osztály | Kor | Távolság | Tömeg
13 |  |  |  | >600 |
14 |  |  |  |  |

Mint ebben az egyszerű példában, néha kívánatos (de nem feltétlenül szükséges), hogy a keresési feltételek területe közvetlenül az adatbázis-tábla alá kerüljön, a két terület oszlopai pedig függőlegesen igazodjanak egymáshoz. A keresési feltételek területén lévő üres bejegyzéseket a rendszer figyelmen kívül hagyja. A fenti példa adatbázis-táblájával és ezzel a keresési feltételek területével illessze be az =AB.DARAB(A1:E10;;A12:E14) képletet a lap egy üres cellájába máshol, hogy megszámolja, hányan utaznak József vendégei közül 600 méternél messzebbre az iskolába. Az 5 értéket kapjuk vissza (Bettina, Dániel, Éva, Henrik és Irén megszámlálásával).

Note also that the formula =DCOUNT(A1:E10;;D12:D13) returns exactly the same value, demonstrating that it is only necessary for the search criteria area to contain relevant column headings.

#### 2. példa

| A | B | C | D | E
12 |  | Kor | Osztály |  |
13 |  | >7 | 2 |  |
14 |  |  |  |  |

Ebben a példában a keresési feltételek területe csak két címsort tartalmaz, és ezek nincsenek függőlegesen összehangolva a példa adatbázis táblájának megfelelő címsorával. Mivel egy sorban két feltétel van, ezeket ÉS kapcsolja össze. A fenti példa adatbázis-táblával és ezzel a keresési feltételek területével illesszük be az =AB.DARAB(A1:E10;;B12:C13) képletet a lap egy üres cellájába máshol, hogy megszámoljuk, hányan vannak József vendégei közül, akik a 2. osztályban vannak és 7 évesnél idősebbek. A 2 értéket kapjuk vissza (Évát és Irént számolva).

#### 3. példa

| A | B | C | D | E
12 |  | Kor |  |  |
13 |  | 9 |  |  |
14 |  | 10 |  |  |

In this example the search criteria area contains only one heading. Since there are two conditions in consecutive rows, these are connected by OR. With the above example database table and this search criteria area, insert the formula =DCOUNT(A1:E10;;B12:B14) into an empty cell elsewhere in the sheet to count how many of Joe’s guests are either 9 or 10 years old. The value 4 is returned (counting Andy, Betty, Charles, and Harry).

#### 4. példa

| A | B | C | D | E
12 |  | Kor | Kor |  |
13 |  | >=8 | <=10 |  |
14 |  |  |  |  |

Ebben a példában a keresési feltételek területe tartalmazza ugyanannak a címnek két előfordulását. Mivel két feltétel van ugyanabban a sorban, ezeket ÉS kapcsolja össze. A fenti példa adatbázis táblájával és ezzel a keresési feltétel területtel illesszük be az =AB.DARAB(A1:E10;;B12:C13) képletet a lap egy üres cellájába máshol, hogy megszámoljuk, Joe vendégei közül hányan 8 és 10 év közöttiek. 6-ot kapunk értékként (Andy, Betty, Charles, Eva, Harry és Irene megszámlálásával).

#### 5. példa

| A | B | C | D | E
12 | Név |  |  |  |
13 | F* |  |  |  |
14 |  |  |  |  |

This simple example shows the use of wildcards. For this example to work as intended, select to enable wildcards at LibreOffice - Preferences Tools - Options - LibreOffice Calc - Calculate. With the above example database table and this search criteria area, insert the formula =DCOUNT(A1:E10;;A12:A13) into an empty cell elsewhere in the sheet to count how many of Joe’s guests have names that begin with the letter “F”. The value 1 is returned (counting Frank).

#### 6. példa

| A | B | C | D | E
12 | Név |  |  |  |
13 | [ABC].* |  |  |  |
14 |  |  |  |  |

Ez az egyszerű példa a reguláris kifejezések használatát mutatja be. Ahhoz, hogy ez a példa rendeltetésszerűen működjön, engedélyezze a reguláris kifejezések használatát a LibreOffice - Beállítások Eszközök - Beállítások - LibreOffice Calc - Számítás menüparanccsal. A fenti példa adatbázis-táblájával és ezzel a keresési feltételek területével illessze be az =AB.DARAB(A1:E10;;A12:A13) képletet a lap egy üres cellájába máshol, hogy megszámolja, Joe vendégei közül hánynak neve kezdődik "A", "B" vagy "C" betűvel. A 3 értéket kapjuk vissza (Andy, Betty és Charles megszámlálásával).

## AB.DARAB

DCOUNT counts the number of cells (fields) of the specified column that contain numeric values, for all rows (database records) that match the specified search criteria. However, if no column is specified, DCOUNT returns the count of all records that match the specified search criteria irrespective of their contents.

#### Szintaxis

AB.DARAB(adatbázis; [adatbázismező]; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">600" (this search criterion will match records in the database table that have a value greater than 600 in the Distance column).

Insert the formula =DCOUNT(A1:E10;; A12:E13) into an empty cell elsewhere in the sheet to calculate how many of Joe’s party guests travel further than 600 meters to school. The value 5 is returned.

The same result is obtained if you use the formula =DCOUNT(A1:E10; "Distance"; A12:E13), because all entries in the Distance column are numeric. However, if you use the formula =DCOUNT(A1:E10; "Name"; A12:E13), the value 0 is returned because all entries in the Name column are non-numeric.

## AB.DARAB2

DCOUNTA counts the number of cells (fields) of the specified column that are not blank, for all rows (database records) that match the specified search criteria. Blank cells of the specified column are not counted. However, if no column is specified, DCOUNTA returns the count of all records that match the specified search criteria irrespective of their contents.

#### Szintaxis

AB.DARAB2(adatbázis; [adatbázismező]; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">600" (this search criterion will match records in the database table that have a value greater than 600 in the Distance column).

Insert the formula =DCOUNTA(A1:E10;; A12:E13) into an empty cell elsewhere in the sheet to calculate how many of Joe’s party guests travel further than 600 meters to school. The value 5 is returned.

The same result is obtained if you use the formula =DCOUNTA(A1:E10; "Distance"; A12:E13) or the formula =DCOUNTA(A1:E10; "Name"; A12:E13). The latter case reflects that in contrast to DCOUNT, DCOUNTA counts both numeric and alphanumeric values in the column indicated by the DatabaseField argument.

## AB.MAX

DMAX calculates the maximum value across the cells (fields) of the specified column that contain numeric values, for all rows (database records) that match the specified search criteria. Blank cells or cells containing non-numeric characters are not included.

Returns 0 if no matches are found, or if there are no non-zero numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.MAX(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DMAX(A1:E10; "Distance"; A12:E13) into an empty cell elsewhere in the sheet to find the maximum distance in meters that any of Joe’s party guests travel to school. The value 1200 is returned.

## AB.MEZŐ

DGET returns the contents of the cell (field) of the specified column, for the single row (database record) that matches the specified search criteria.

Calc reports Err:502 (invalid argument) if multiple matches are found, or a #VALUE! error (wrong data type) if no matches are found. A #VALUE! error is also reported if a single match is found but the relevant cell is empty.

#### Szintaxis

AB.MEZŐ(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell C13 which should contain "11" (this search criterion will match records in the database table that have a value of 11 in the Age column).

Insert the formula =DGET(A1:E10; "Name"; A12:E13) into an empty cell elsewhere in the sheet to find the name of Joe’s party guest who is age 11. The name Daniel is returned.

If you change the value in cell C13 to “10”, then the formula =DGET(A1:E10; "Name"; A12:E13) returns an invalid argument error (Err:502). The reflects that multiple records match the specified criterion (both Betty and Charles are age 10).

## AB.MIN

DMIN calculates the minimum value across the cells (fields) of the specified column that contain numeric values, for all rows (database records) that match the specified search criteria. Blank cells or cells containing non-numeric characters are not included.

Returns 0 if no matches are found, or if there are no non-zero numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.MIN(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DMIN(A1:E10; "Distance"; A12:E13) into an empty cell elsewhere in the sheet to find the minimum distance in meters that any of Joe’s party guests travel to school. The value 150 is returned.

## AB.SZORZAT

DPRODUCT calculates the product of all numeric values in the cells (fields) of the specified column, for all rows (database records) that match the specified search criteria. Blank cells or cells containing non-numeric characters are not included.

Returns 0 if no matches are found, or if there are no numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.SZORZAT(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell C13 which should contain ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DPRODUCT(A1:E10; "Age"; A12:E13) into an empty cell elsewhere in the sheet to calculate the product of the ages in years of Joe’s party guests. The value 279417600 is returned.

## AB.SZUM

DSUM calculates the sum of all numeric values in the cells (fields) of the specified column, for all rows (database records) that match the specified search criteria. Blank cells or cells containing non-numeric characters are not included.

Returns 0 if no matches are found, or if there are no numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.SZUM(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DSUM(A1:E10; "Distance"; A12:E13) into an empty cell elsewhere in the sheet to find the total distance in meters that all of Joe’s party guests travel to school. The value 6000 is returned.

## AB.SZÓRÁS

DSTDEV calculates the sample standard deviation based on the numeric values in the cells (fields) of the specified column, for all rows (database records) that match the specified search criteria. Non-numeric values are ignored.

Returns a #NUM! error if exactly one record matches the specified search criteria, or if there is only one numeric value in the cells of the specified column for the matching records.

Returns 0 if no matches are found, or if there are no numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.SZÓRÁS(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:D13 are blank and that cell E13 contains ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DSTDEV(A1:E10; "Weight"; A12:E13) into an empty cell elsewhere in the sheet to calculate the sample standard deviation of the weights in kg of Joe’s party guests. The value 5.5 is returned.

## AB.SZÓRÁS2

DSTDEVP calculates the population standard deviation based on the numeric values in the cells (fields) of the specified column, for all rows (database records) that match the specified search criteria. Non-numeric values are ignored.

Returns a #NUM! error if no records match the specified search criteria, or if there are no numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.SZÓRÁS2(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:D13 are blank and that cell E13 contains ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DSTDEVP(A1:E10; "Weight"; A12:E13) into an empty cell elsewhere in the sheet to calculate the population standard deviation of the weights in kg of Joe’s party guests. The value 5.18545 is returned.

## AB.VAR

DVAR calculates the sample variance based on the numeric values in the cells (fields) of the specified column, for all rows (database records) that match the specified search criteria. Non-numeric values are ignored.

Returns a #NUM! error if exactly one record matches the specified search criteria, or if there is only one numeric value in the cells of the specified column for the matching records.

Returns 0 if no matches are found, or if there are no numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.VAR(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DVAR(A1:E10; "Distance"; A12:E13) into an empty cell elsewhere in the sheet to find the sample variance of the distances in meters that Joe’s party guests travel to school. The value 193125 is returned.

## AB.VAR2

DVARP calculates the population variation based on the numeric values in the cells (fields) of the specified column, for all rows (database records) that match the specified search criteria. Non-numeric values are ignored.

Returns a #NUM! error if no records match the specified search criteria, or if there are no numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.VAR2(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DVARP(A1:E10; "Distance"; A12:E13) into an empty cell elsewhere in the sheet to find the population variance of the distances in meters that Joe’s party guests travel to school. The value 171666.67 is returned.

## AB.ÁTLAG

DAVERAGE calculates the average of the numeric values in the cells (fields) of the specified column, for all rows (database records) that match the specified search criteria. Non-numeric values in those cells are ignored.

Returns a #DIV/0! error if no records match the specified search criteria, or if there are no numeric values in the cells of the specified column for the matching records.

#### Szintaxis

AB.ÁTLAG(adatbázis; adatbázismező; keresési_feltétel)

#### Példa

The example database table giving information about the guests invited to Joe’s birthday party (described above) should occupy cells A1:E10. The content of cells A12:E12 should be identical to the header labels for the database table in cells A1:E1. Make sure that cells A13:E13 are blank, except for cell D13 which should contain ">0" (this search criterion is intended to match all records in the database table).

Insert the formula =DAVERAGE(A1:E10; "Distance"; A12:E13) into an empty cell elsewhere in the sheet to calculate the average distance in meters travelled to school by Joe’s party guests. The value 666.67 is returned.

Kapcsolódó témakörök

Függvények kategória szerint