> For the complete documentation index, see [llms.txt](https://docs.ngsurvey.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ngsurvey.com/de/projects/import-export/xlsform/umfrageblatt/berechnungen.md).

# Berechnungen

Berechnungen werden verwendet, um versteckte Felder zu erstellen, die automatisch Werte basierend auf anderen Antworten im Formular berechnen.

In XLSForm werden Berechnungen mithilfe der `calculate` Fragentyp definiert. Diese Felder werden dem Benutzer nicht angezeigt, sie laufen im Hintergrund und speichern Ergebnisse für spätere Verwendung oder Analyse.

In ngSurvey werden berechnete Werte als versteckte Felder gespeichert und in den Formulardaten ausgegeben, genau wie andere Antworten.

## 🔢 Wie man eine Berechnung definiert

Um eine Berechnung zu erstellen:

1. Verwenden Sie den Typ `calculate` im `survey` Sheet.
2. Weisen Sie dem Feld einen Namen zu.
3. Verwenden Sie die `calculation` Spalte, um die Logik zu definieren.
4. Optional können Sie die `label` Spalte für interne Referenzen verwenden (sie wird dem Benutzer nicht angezeigt).

#### Beispiel: Gesamtpunktzahl aus mehreren Antworten

| Typ       | name         | calculation           |
| --------- | ------------ | --------------------- |
| integer   | q1           |                       |
| integer   | q2           |                       |
| integer   | q3           |                       |
| calculate | total\_score | ${q1} + ${q2} + ${q3} |

In diesem Beispiel:

* Der Benutzer beantwortet drei numerische Fragen (`q1`, `q2`, `q3`).
* Das `total_score` Feld addiert diese drei Werte miteinander.
* Der Wert von `total_score` wird in den Formulardaten gespeichert, obwohl er niemals angezeigt wird.

#### Nützliche Berechnungsfunktionen

Sie können die meisten Standardoperatoren und -funktionen verwenden, wie z. B.:

* Mathe: `+`, `-`, `*`, `div`, `mod`
* Text:  `string-length(), regex, round, substr, concat`
* Logik: `if(condition, true, false)`, `coalesce()`
* Datum: `today()`, `now()`, `date()`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ngsurvey.com/de/projects/import-export/xlsform/umfrageblatt/berechnungen.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
