# Data-expressions

{% embed url="<https://vimeo.com/503533954>" %}

A data-expression is an advanced functionality. Its purpose is to **avoid having to recreate certain calculations across different clauses.**

## Example use case <a href="#example-use-case" id="example-use-case"></a>

Assume that a contract has a datafield *#ordered-items^price*, and another datafield *#ordered-items^amount*. It is not necessary — even to be avoided — to then also have a datafield to store the total price to be paid by the customer, because this price can be easily calculated on the basis of the two other fields. For example, assuming a VAT rate of 21%, the formula would be:

{% code overflow="wrap" %}

```
(#ordered-items^price * #ordered-items^amount) * 1.21.
```

{% endcode %}

It is, however, cumbersome to insert this calculation every time the total price needs to show up in a clause. Moreover, writing this calculation over and over again is error-prone, and difficult to manage if the calculation should be changed (e.g., if due to changes in negotiations some additional markup costs needs to be incorporated in the total price; if the VAT rate would change, etc).

Data-expressions allow you to centrally store calculations, and use them as if they were a simple datafield. In our example, the *#ordered-items* concept could thus be assigned a datafield *total-price* that would contain the calculation above. Each time the calculation is required, you can simply refer to *#ordered-items^total-price*.

## Structure of data-expressions <a href="#structure-of-dataexpressions" id="structure-of-dataexpressions"></a>

A data-expression can be either a single expression, or a set of conditioned expressions.

### Single expression <a href="#single-expression" id="single-expression"></a>

A data-expression with a single expression consists of any valid expression


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.clause9.com/datafields/data-expressions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
