Contents
Index 🔎︎

# Databasfunktioner

I det här avsnittet beskrivs funktioner som används med data som organiserats i en rad för en post.

Databaskategorin kan förväxlas med en databas som integrerats i LibreOffice. Det finns emellertid ingen koppling mellan en databas i LibreOffice och databaskategorin i LibreOffice Calc.

### Exempeldata:

Följande data kommer att användas i några av de exempel som beskriver funktionerna:

Området A1:E10 innehåller en lista över barn som är bjudna till Johans födelsedagskalas. Följande information är angiven för varje post: kolumn A visar namn, B visar årskurs, sedan visas ålder i år, skolväg i meter och kroppsvikt i kilo.

| A | B | C | D | E
1 | Namn | Grad | Ålder | Avstånd till skolan | Vikt
2 | Anders | 3 | 9 | 150 | 40
3 | Elisabeth | 4 | 10 | 1000 | 42
4 | Karl | 3 | 10 | 300 | 51
5 | Daniel | 5 | 11 | 1200 | 48
6 | Eva | 2 | 8 | 650 | 33
7 | Grad | 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 | Namn | Grad | Ålder | Avstånd till skolan | Vikt
14 |  |  |  | >600 |
15 |  |  |  |  |
16 | DANTAL | 5 |  |  |

Formeln i cell B16 är =DANTAL (A1:E10;0;A13:E14)

### Parametrar för databasfunktioner:

Följande objekt är parameterdefinitioner för alla databasfunktioner:

databas är det cellområde som definierar databasen.

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.

Sökkriterier är det cellområde som innehåller sökkriterier. Om du skriver olika kriterier i en rad sammankopplas de av OCH. Om du skriver olika kriterier i olika rader sammankopplas de av ELLER. Tomma celler i sökkriterieområdet ignoreras.

Choose LibreOffice - PreferencesTools - 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.

## DANTAL

DANTAL räknar antalet rader (poster) i en databas som matchar angivna sökvillkor, och innehåller numeriska värden.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DANTAL(Databas; [Databasfält]; Sökkriterier)

If the DatabaseField argument is omitted, DCOUNT 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.

#### Example

I exemplet ovan (bläddra uppåt) har vi tagit reda på hur många av barnen som bor mer än 600 meter från skolan. Resultatet sparas i cell B16. Placera markören i cell B16. Ange formeln =DANTAL(A1:E10;0;A13:E14) i B16. Med hjälp av Funktionsguiden matar du in områden.

Databas är det dataområde som ska beräknas, inklusive rubrikerna, i det här fallet A1:E10. Databasfält anger kolumnen för sökriterierna, i det här fallet hela databasen. Sökkriterier är det område där du kan ange sökparametrarna, i det här fallet A13:E14.

Om du vill veta hur många barn som är över sju år i andra årskursen, raderar du posten >600 i cell D14 och anger 2 i cell B14 under Grad. Ange sedan >7 i cell C14 till höger. Resultatet blir 2. Två barn går i andra årskurs och är över sju år. Eftersom båda kriterierna är i samma rad sammankopplas de av OCH.

## DANTALV

DANTALV räknar antalet rader (poster) i en databas som matchar angivna sökvillkor, och innehåller numeriska eller alfanumeriska värden.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DANTALV(Databas; [Databasfält]; Sökkriterier)

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.

#### Example

I exemplet ovan (bläddra uppåt) kan du ta reda på hur många barn som har ett namn som börjar på bokstaven E eller någon efterföljande bokstav. Ange följande formel i B16: =DANTALV(A1:E10;"Namn";A13:E14). Ta bort gamla sökkriterier och ange >=E under Namn i fältet A14. Resultatet blir 5. Om du tar bort alla nummervärden för Greta på rad 8 ändras resultatet till 4. Rad 8 beräknas inte längre eftersom den inte innehåller några värden. Namnet Greta är text, inte ett värde. Observera att parametern Databasfält måste peka på en kolumn som kan innehålla värden.

## DHÄMTA

DHÄMTA returnerar innehållet i den refererade cellen i databasen som matchar angivet sökkriterium. Om ett fel inträffar returneras antingen #VÄRDEFEL! om ingen rad hittas, eller Err502 om fler än en cell hittas.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DHÄMTA (Databas; Databasfält; Sökkriterier)

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.

#### Example

I exemplet ovan (bläddra uppåt) tar vi reda på vilken årskull ett barn, vars namn angavs i cell C14, tillhör. Formeln anges i cell B16 och skiljer sig något från tidigare exempel eftersom endast en kolumn (ett databasfält) kan anges som Databasfält. Ange följande formel:

=DHÄMTA(A1:E10;"Grad";A13:E14)

Om du anger namnet Frank i A14 blir resultatet 2. Frank tillhör den andra graden. Om du anger "Ålder" i stället för "Grad" får du reda på Franks ålder.

Du kan även ange värdet 11 endast i cell C14 och ta bort andra poster på den här raden. Så här redigerar du formeln i B16:

=DHÄMTA(A1:E10;"Namn";A13:E14)

Nu frågar du alltså efter namnet, och inte klassen. Svaret får du direkt: Daniel är det enda barnet som är 11 år gammalt.

## DMAX

DMAX returnerar maxinnehållet i en cell (fält) i en databas (alla poster) som matchar angivna sökkriterier.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DMAX (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill veta hur mycket det tyngsta barnet i varje årskurs väger i exemplet ovan (bläddra uppåt) skriver du följande formel i B16:

=DMAX(A1:E10;"Vikt";A13:E14)

Ange 1, 2, 3, osv. efter varandra under Grad. Om du anger gradnummer visas barnet som väger mest inom den graden.

## DMEDEL

DMEDEL returnerar medelvärdet av värdena i alla celler (fält) i alla rader (databasposter) som matchar angivet sökkriterium.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DMEDEL (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill visa medelvikten för alla barn i samma ålder i exemplet ovan (bläddra uppåt) skriver du följande formel i B16:

=DMEDEL(A1:E10;"Vikt";A13:E14)

Ange 7, 8, 9, osv. efter varandra på rad 14 under Ålder. Medelvikten för alla barnen i samma årskull visas.

## DMIN

DMIN returnerar minimiinnehållet i en cell (fält) i en databas som matchar angivna sökkriterier.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DMIN (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill ta reda på den kortaste skolvägen för barnen i varje årskurs i exemplet ovan (bläddra uppåt) skriver du följande formel i B16:

=DMIN(A1:E10;"Avstånd till skolan";A13:E14)

Ange 1, 2, 3, osv. efter varandra på rad 14 under Grad. Den kortaste skolvägen för barnen i varje årskurs visas.

## DPRODUKT

DPRODUKT multiplicerar alla celler i ett dataområde där cellinnehållet matchar sökkriteriet.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DPRODUKT (Databas; Databasfält; Sökkriterier)

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.

#### Example

Funktionen går inte att tillämpa meningsfullt på födelsedagskalaset i exemplet ovan (bläddra uppåt).

## DSTDAV

DSTDAV beräknar standardavvikelsen för en population baserad på ett stickprov, och använder de siffror i en databaskolumn som matchar angivna villkor. Posterna behandlas som stickprov. Det innebär att barnen i exemplet representerar ett tvärsnitt av alla barn. Observera dock att representativa resultat inte kan fås från ett urval på mindre än tusen personer.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DSTDAV (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill visa standardavvikelsen för vikten hos alla barn i samma ålder i exemplet (bläddra uppåt) skriver du följande formel i B16:

=DSTDAV(A1:E10;"Vikt";A13:E14)

Ange 7, 8, 9, osv. efter varandra på rad 14 under Ålder. Resultatet som visas är standardavvikelsen för barns vikt i samma ålder.

## DSTDAVP

DSTDAVP beräknar standardavvikelsen för en population baserad på alla celler i ett dataområde som matchar sökkriterierna. Dataposterna i exemplet behandlas som hela populationen.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DSTDAVP (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill visa standardavvikelsen för vikten hos alla barn i samma ålder på Johans födelsedagskalas (bläddra uppåt) skriver du följande formel i B16:

=DSTDAVP(A1:E10;"Vikt";A13:E14)

Ange 7, 8, 9, osv. efter varandra på rad 14 under Ålder. Resultatet är standardavvikelsen för vikten hos alla jämnåriga barn som undersökts.

## DSUMMA

DSUMMA returnerar summan för alla celler i ett databasfält i alla rader (poster) som matchar angivna sökkriterier.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DSUMMA (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill ta reda på den sammanlagda skolvägen för alla barn på Johans födelsedagskalas som går i andra klass (bläddra uppåt), anger du följande formel i B16:

=DSUMMA(A1:E10;"Avstånd till skolan";A13:E14)

Ange 2 på rad 14 under Grad. Summan (1950) för skolavståndet för alla barn som går i årskurs 2 visas.

## DVARIANS

DVARIANS returnerar variansen för alla celler i ett databasfält, i alla poster som matchar angivna sökkriterier. Posterna i exemplet behandlas som ett stickprov. Det går inte att få representativa resultat från ett urval på mindre än tusen personer.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DVARIANS (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill visa variansen för alla barn i samma ålder i exemplet ovan (bläddra uppåt) skriver du följande formel i B16:

=DVARIANS(A1:E10;"Vikt";A13:E14)

Ange 7, 8, 9, osv. efter varandra på rad 14 under Ålder. Då visas variansresultatet för barns vikt i samma ålder.

## DVARIANSP

DVARIANSP beräknar variansen för alla celler i ett databasfält, i alla poster som matchar angivna sökkriterier. Dataposterna i exemplet behandlas som en hel population.

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 LibreOffice - PreferencesTools - Options - LibreOffice Calc - Calculate.

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

#### Syntax

DVARIANSP (Databas; Databasfält; Sökkriterier)

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.

#### Example

Om du vill visa variansen för vikten hos alla barn i samma ålder på Johans födelsedagskalas (bläddra uppåt) skriver du följande formel i B16:

=DVARIANSP(A1:E10;"Vikt";A13:E14)

Ange 7, 8, 9, osv. efter varandra på rad 14 under Ålder. Variansen för vikten visas för alla barn i samma ålder som var på Johans födelsedagskalas.

Närliggande ämnen

Functions by Category