Datentabellenverweis

Mit LibreOffice Calc kann auf Daten in Datentabellen verwiesen werden, indem für Zellbezüge innerhalb der Tabelle eine spezielle Schreibweise verwendet wird, ein „Datentabellenverweis“. Diese spezielle Schreibweise soll die Lesbarkeit von Formeln verbessern, die auf Zellen innerhalb einer Datentabelle verweisen.

Datentabellen

Tabellen in Tabellendokumenten werden durch Datenbereiche festgelegt (Daten – Bereich festlegen). Neben dem Namen des Datenbereichs ist Folgendes für die Verwendung von Datentabellenverweise obligatorisch:

Beispiel

Die folgende Tabelle enthält Werte, die in den Beispielen weiter unten in diesem Dokument verwendet werden.

A

B

C

D

1

Name

Region

Absatz

Dienstalter

2

Smith

West

21

5

3

Jones

Ost

23

11

4

Johnson

Ost

9

7

5

Taylor

West

34

11

6

Brown

Ost

23

15

7

Walker

Ost

12

4

8

Edwards

East

15

12

9

Thomas

West

17

10

10

Wilson

West

31

3

11

Summe

2

185

8.67


Der Zellbereich A1:D11 wurde als Datenbereich "meineDaten" festgelegt. Die Optionen Enthält Spaltenbeschriftungen und Enthält Summenzeile wurden beim Festlegen des Datenbereichs aktiviert.

Auf Daten in Tabellen verweisen

Ein Datentabellenverweis hat die Form database_range[…]. Der Teil in den eckigen Klammern kann ein reserviertes Schlüsselwort, ein Feldname in eckigen Klammern oder eine Kombination aus beidem sein.

Wenn ein einzelnes Schlüsselwort oder ein einzelner Feldname verwendet wird, verwenden Sie einfache Klammern statt doppelter Klammern.

Beispiel

meineDaten[#Überschriften] anstelle von meineDaten[[#Überschriften]] oder meineDaten[Region] anstelle von meineDaten[[Region]].

Reserved reference keywords

Keyword

Usage

Example

[#Headers]

The keyword [#Headers] references the row of field names (column labels). It is the first row of the database range.

If the database range has no labels row defined (Contains columns row), a #REF! error is generated.

The expression myData[#Headers] references the cells A1:D1.

[#Data]

The keyword [#Data] references the data records of the database range, excluding the column label row and the totals row.

The short form myData[] can be used as well.

The expression myData[#Data] references the cell rectangle A2:D10.

[#Totals]

The keyword [#Totals] references the row of totals. It is the last row of the database range.

If the database range has no line of totals defined (Contains totals row), a #REF! error is generated.

The expression myData[#Totals] references the cells A11:D11.

[#All]

The keyword [#All] references the entire database range including column labels and totals.

The expression myData[#All] references the cells A1:D11.

[#This Row]

This keyword describes an implicit intersection.

If the expression myData[#This Row] is used in a formula in cell F2, it references A2:D2. If the same expression is used in a formula in cell F5, it references A5:D5.


Field name in square brackets

To reference the array of all values in the records that belong to the same field, use the form [field name]. The referenced cell range does not include label and totals.

Example

The expression myData[[Region]] or its simplified form myData[Region] references the cells B2:B10. If the database range has no label row, generic labels like Column1, Column2 can be used.

note

In Microsoft Excel, if the formula cell belongs to the table, then the name of the table may be omitted. For example, the formula =SUM(myData[Sales]) in cell C11 could be written as =SUM([Sales]). Omission of the table name is not yet possible in Calc.


Combinations

Columns and data records

To reference a combination of the column labels and data records, use the format [#Headers];[#Data] or [#Headers],[#Data], where the separator is the same separator as for function parameters that is defined in Tools - Options - Calc - Formula - Separators.

Data records and total row

To reference a combination of data records and totals row, use [#Data];[#Totals]. For example, myData[[#Data];[#Totals]] references the cells A2:D11.

A combination like [#Headers];[#Totals] is not possible as that would result in two disjoint cell rectangles.

Adjacent columns

To reference several adjacent columns, use the range operator “:”. For example, the formula myData[[Name]:[Sales]] addresses the cells A2:C10.

Non-adjacent columns

The use of non-adjacent columns is not possible since it would reference two separate cell rectangles.

Field name and keyword

The reference via field name and the use of a reference keyword can be combined. First state the keyword, then the function separator, and last the field name in brackets. For example, myData[[#Totals];[Sales]] references the cell C11.