Documentation/Calc Functions/DMIDDEL

From The Document Foundation Wiki
Jump to navigation Jump to search
This page is a translated version of the page Documentation/Calc Functions/DAVERAGE and the translation is 42% complete.
Outdated translations are marked like this.
Other languages:
English • ‎dansk



Funktionsnavn:

DAVERAGE

Kategori:

Database

Resume:

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

Syntax:

DAVERAGE(Database; DatabaseField; SearchCriteria)

Returns:

Returns a real value by calculating average of the all cells in the Database that qualify the SearchCriteria in the given DatabaseField.

Argumenter:

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.

Calc provides two methods for assigning names to cell ranges and these are known as named ranges and database ranges. The Database argument may also be specified by passing the name of a defined named range or database range. Using a meaningful name to define the cell range can enhance formula readability and document maintenance.

Im-jabber.svg

Note:
Unlike the named range, the Database range can be connected to a data source, from where you can fetch data into the spreadsheet document. See the Additional Details section below for more details.

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).

• 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 point. If the value is less than 1, Calc reports Err:504 (error in parameter list). If the value is greater than the number of columns in Database, Calc reports a #VALUE! 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 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.


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. The contents of the SearchCritera area are described in more detail in the Additional Details section below.

  • See also the Wiki page about Conditional Counting and Summation.
  • For the Database, 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).
  • For the SearchCriteria, 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.
  • If the SearchCriteria is not qualified or DatabaseField is non-numeric, then the function returns a division error(#DIV/0!) since number of entries is 0.

Yderligere oplysninger:

Eksempler:


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.

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
11
12
13 Name Grade Age Distance to School Weight
14 >600
15
16 DCOUNT 5

The formula in cell B16 is =DCOUNT(A1:E10;D1;A13:E14)


Formula Description Returns
=DAVERAGE(A1:E10;D1;A13:E14) average distance to school where distance to school is greater than 600 1010
=DAVERAGE(A1:E10;"Weight";A13:E14) average weight of students for whom distance to school is greater than 600 41.8
=DAVERAGE(A1:E10;"Age";A13:E14) where we enter 1 in cell B14 under Grade search criteria is not qualified so the function returns division error #DIV/0!

I række 14, under Alder, prøver du at indtaste 7, 8, 9 osv. ét tal ad gangen. Gennemsnitsvægten, afstanden til skolen for alle børn med den bestemte alder og mere end 600 m til skole vises for de samme formler som ovenfor.

For more detailed examples, download and view this Calc spreadsheet.

Beslægtede LibreOffice-funktioner:

MIDDEL

TÆL

DTÆLV

DSUM

ODF standard:

Tilsvarende Excel-funktioner:

DMIDDEL