> For the complete documentation index, see [llms.txt](https://documentation.ardoq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.ardoq.com/data-model/fields/reactive-fields.md).

# Reactive Fields

Visualize real-time insights with dynamically calculated fields based on your component data.

Reactive fields calculate field values in Ardoq using simple arithmetic or lookup tables and display results in real time. Reactive fields are perfect for common use cases within a single component where immediate output is essential.

For example, when assessing risk, you can configure a reactive field to update the Risk Level number (e.g. from 1 to 3) when the associated Risk field changes from Low to High — allowing your visualizations to update without manual updates.

Reactive fields provide a dynamic way to update values within a single component based on other fields in that component without resorting to [Gremlin-based calculated fields](/data-model/fields/calculated-fields.md).

Reactive fields are currently supported the following field types:

* Text
* Number
* List

## Creating a Reactive Field

1. Click your organization name in the top-left corner and select **Admin** > **Metamodel** then the **Fields** tab.&#x20;
2. Select the field you want to use as a reactive field or create a new one.
3. Under the **Transformations and Gremlin** dropdown, select the applicable reactive transformation (see the [Available Transformations per Field Type](#available-transformations-per-field-type) table for a list of all transformation), and configure it.
4. Click **Save** (or **Create** if making a new field) to finalize your reactive field.

<figure><img src="https://2484004798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnlnB7uZ29iLVLzqGbCym%2Fuploads%2FfbElBY3nGxQHuaaOBLC1%2Fimage.png?alt=media&amp;token=cc6aed2a-5f56-47c0-86dd-c1ec60d370de" alt=""><figcaption><p>Example reactive field options for the <strong>Text</strong> field type.</p></figcaption></figure>

### Available Transformations per Field Type

| Field Type | Operation Available | Input Field Types                       |
| ---------- | ------------------- | --------------------------------------- |
| Text       | Dictionary Lookup   | Number, Text, List                      |
| Text       | Concatenate Fields  | Number, Text, List, Ardoq ID, Ardoq OID |
| List       | Dictionary Lookup   | Number, Text, List                      |
| Number     | Dictionary Lookup   | Number, Text, List                      |
| Number     | Math Expression     | Number                                  |

## Detailed Operation Descriptions

### Dictionary Lookup

The Dictionary Lookup transformations allows the creation of mappings between different values. For instance, you can map text-based service levels like Platinum, Gold, Silver, and Bronze to numerical values like 5, 4, 3, and 2.

<figure><img src="https://2484004798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnlnB7uZ29iLVLzqGbCym%2Fuploads%2FZrme3rUeANA2s1yBmGzV%2Fimage.png?alt=media&amp;token=0f3771cc-8b85-4d46-95f5-3d52bb4847ea" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The dictionary lookup supports number fields as both the input field type and output, but **decimal values are not supported**. Any mapping rule with decimal values will be rounded down to the nearest integer.
{% endhint %}

### Concatenate Fields

The Concatenate transformation allows for the combination of multiple values into a single text value using a separator value. For example, you can combine first name and last name values into a single full name value using the space separator.

### Math Expression

The Math expression transformation allows for the creation of basic arithmetic functions using numerical fields. Use the **@** symbol to open the reference dropdown and select relevant values.

<figure><img src="https://2484004798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnlnB7uZ29iLVLzqGbCym%2Fuploads%2FsCBIfn67rZTLPN3U6Pfi%2Fimage.png?alt=media&amp;token=46fe498f-cc13-42d3-8fa8-cd81d95959fa" alt=""><figcaption></figcaption></figure>

The following elements are supported in math expressions:

* **Numbers:** Integers (e.g., `10`, `-5`) and decimals (using a period as the decimal separator, e.g., `3.14`, `-0.5`).
* **Fields:** References to other number fields (e.g., `@my_field`, `@another_field`).
* **Operators:** `+` (addition), `-` (subtraction or negation), `*` (multiplication), `/` (division). The minus sign (`-`) can also be used as a unary operator to negate a field (e.g., `-@my_field`).
* **Parentheses:** `()` for grouping and order of operations (e.g., `(2 + 3) * 5`).

Formulas can be arbitrarily complex and nested as long as they use only these building blocks.

#### **Chaining Operations with Intermediate Fields**

For complex calculations, it's often helpful to break them down into smaller, more manageable steps using intermediate fields. This allows you to "chain" multiple operations together. Say for instance that you have list fields for probability and impact and you wish to calculate risk. You would then create `numeric probability` and `numeric impact` which would map `high`, `medium`, `low` to `3`, `2`, `1` for instance. You can then create `numeric risk` which is multiplying the two other numeric fields and finally `risk` which maps `1`, `2` and `3` to `low`, `4`, `5` and `6` to `medium`, etc

#### **Handling Empty Fields in Math Expressions**

When performing calculations with fields that might be empty, using intermediate fields with default values is essential. Say you have a numeric `rating` field which you want to calculate on, but some components doesn't have it filled out. If you create a reactive field `rating or default` with the math expression `@rating` and default value `0`, you can then use `@rating_or_default` in another math expression. If the `rating` is empty, the math expression using `@rating_or_default` will still get a value, unlike the empty result it would have if it was using `rating` directly

## Scenarios Support

Unlike calculated fields, reactive fields are supported within Scenarios, making them a powerful tool for "what-if" analysis.

## Frequently Asked Questions (FAQ)

<details>

<summary><strong>What are the key differences between Reactive Fields and Calculated Fields?</strong></summary>

While both reactive and calculated fields derive their values from other fields, they have some differences:

* **Scope:** Reactive fields operate *within* a single component or reference, while calculated fields (using Gremlin) can traverse relationships between components. This means calculated fields can pull data from related components across your model, while reactive fields are limited to the data within the current component or reference.
* **Performance:** Reactive fields update near-instantly, while calculated fields are scheduled to run every hour and also may have a longer update time, especially with complex queries. The near-instant updates of reactive fields are ideal for real-time feedback.
* **Complexity:** Reactive fields are limited to simple dictionary lookups and math expressions, while calculated fields offer the full power of the Gremlin graph query language. This makes calculated fields much more powerful for complex data manipulations.

</details>

<details>

<summary><strong>When should I use Reactive Fields versus Calculated Fields?</strong></summary>

Choose reactive fields for simple, local calculations within a single component where real-time updates are crucial. For more complex calculations involving related components or more sophisticated logic, calculated fields are the better choice.

</details>

<details>

<summary><strong>Who will benefit from Reactive Fields?</strong></summary>

Reactive fields are perfect for workspace administrators who need quick, on-the-spot calculations within a single component.

</details>
