Documentation/Calc Functions/DMIDDEL
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
DMIDDEL
Kategori:
Database
Resume:
Dette er en af funktionerne i kategorien Database, der hjælper dig med at analysere en simpel database, der optager et rektangulært regnearksområde, der omfatter kolonner og rækker, med data organiseret som én række for hver post. Overskriftscellen i hver kolonne viser navnet på kolonnen, og det navn afspejler normalt indholdet af hver celle i den kolonne.
DMIDDEL 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.
Syntaks:
DMIDDEL(Database; DatabaseField; SearchCriteria)
Returnerer:
Returns a real number that is the average of the extracted numeric values.
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.
Argumenter:
Overview of arguments
All functions in the Database category take three arguments as follows:
- Database. The cell range of the database.
- DatabaseField. The column containing the data to be used in the function’s calculations.
- SearchCriteria. The cell range of a separate area of the spreadsheet containing search criteria.
These arguments are described in more detail in the subsequent sub-sections.
Database argument
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 #NAVN? error.
- Other errors that might be reported as a result of an invalid Database argument are #VÆRDI! and Fejl:504 (error in parameter list).
DatabaseField argument
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 #NAVN? error. If the name is valid but does not correspond to one cell only, Calc reports Fejl:504 (error in parameter list).
- By entering a number to specify the column within the Database area, starting with 1. For example, if a Database occupied the cell range D6:H123, then enter 3 to indicate the header cell at F6. Calc expects an integer value that lies between 1 and the number of columns defined within Database and ignores any digits after a decimal separator. If the value is less than 1, Calc reports Fejl:504 (error in parameter list). If the value is greater than the number of columns in Database, Calc reports a #VÆRDI! error.
- 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 Fejl: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 DTÆL and DTÆLV functions but it is required for the other Database functions.
SearchCriteria argument
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.
- 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 #NAVN? error.
- Fejl: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 "Yderligere oplysninger:" section below.
Yderligere oplysninger:
Outline concept of operation
- All functions in the Database category 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.
- The Database category of functions in Calc is sometimes confused with a database managed using LibreOffice Base. However, there is no connection between a database in Base and Calc's Database functions.
Defining search criteria
- 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 ("
<, <=, =, <>, >=, >
"). The "=
" operator 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 OG. If you write several criteria in different rows, they are connected by ELLER.
- Criteria can be created using wildcards, providing that wildcards have been enabled via the
Enable wildcards in formulas
option on the ▸ ▸ ▸ dialog ( ▸ ▸ ▸ on macOS). 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 ▸ ▸ ▸ dialog.
- Another setting that affects how the search criteria are handled is the
Search criteria = and <> must apply to whole cells
option on the ▸ ▸ ▸ 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. - Many more examples of these search criteria can be found in this Calc spreadsheet.
Dates and logical values
Dates and logical values (SAND and FALSK) are treated as numeric when calculating with the Database fuctions.
Eksempler:
The following database table occupies cells A1:E10 of an otherwise empty sheet and lists imagined information about the guests invited to Joe's birthday party. For each guest, the table lists their name, school grade, age (in years), distance to school (in meters), and weight (in kilograms).
A | B | C | D | E | |
---|---|---|---|---|---|
1 | Name | Grade | Age | Distance to School | Weight |
2 | Andy | 3 | 9 | 150 | 40 |
3 | Betty | 4 | 10 | 1000 | 42 |
4 | Charles | 3 | 10 | 300 | 51 |
5 | Daniel | 5 | 11 | 1200 | 48 |
6 | Eva | 2 | 8 | 650 | 33 |
7 | Frank | 2 | 7 | 300 | 42 |
8 | Greta | 1 | 7 | 200 | 36 |
9 | Harry | 3 | 9 | 1200 | 44 |
10 | Irene | 2 | 8 | 1000 | 42 |
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).
Formel | Beskrivelse | Returnerer |
---|---|---|
=DMIDDEL(A1:E10; "Distance to School"; A12:E13) | Enter this formula into an empty cell elsewhere in the sheet to calculate the average distance in meters travelled to school by Joe’s party guests. | 666,666666666667 |
Many more examples of both search criteria and function calls can be found in this Calc spreadsheet.
Beslægtede LibreOffice-funktioner:
ODF standard:
Relaterede (eller lignende) Excel-funktioner:
DAVERAGE