> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/administration-and-setup/workflow/cards-overview/then/table/calculate-in.md).

# Calculate in

<figure><img src="https://578966019-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT2n2w4uDCJvv7CJ5zrdk%2Fuploads%2Fgit-blob-9386ae95e96e0757706aca4f5e05db2d00ecade9%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## **Purpose:**

The **"Calculate with Regex Dependency"** workflow card allows users to perform calculations between columns in a selected table, with an added condition based on a regular expression (regex) pattern applied to a dependency column. If the pattern matches, the calculation is performed, and the result is stored in the specified result column.

## **Components of the Card:**

1. **Table Name**
   * **Description:** Specifies the **table** in which the columns will be calculated.
   * **Detail:** A dropdown list of all available **tables** is provided for selection.
2. **Column Name (1st Column)**
   * **Description:** Specifies the **first column** involved in the calculation.
   * **Detail:** A list of all available **columns** is provided for selection.
3. **Operation**
   * **Description:** Defines the mathematical operation to be applied between the selected columns.
   * **Options:**
     * **Add (+):** Adds the value of the second column to the value of the first column.
     * **Subtract (-):** Subtracts the value of the second column from the first column.
     * **Multiply (\*):** Multiplies the value of the first column by the value in the second column.
     * **Divide (/):** Divides the value of the first column by the second column.
4. **Column Name (2nd Column)**
   * **Description:** Specifies the **second column** involved in the calculation.
   * **Detail:** A list of all available **columns** is provided for selection.
5. **Column Name (Dependency)**
   * **Description:** Specifies the **dependency column** to which the regex pattern will be applied.
   * **Detail:** A list of all available **columns** is provided for pattern matching.
6. **Regex Pattern**
   * **Description:** Defines the **regex pattern** that will be used to match against the dependency column.
   * **Detail:** If the value in the dependency column matches the regex pattern, the calculation will be performed.
7. **Result Column**
   * **Description:** Specifies the **result column** where the calculation result will be stored.
   * **Detail:** This can be a new or existing column where the calculated value will be stored.

## **Functionality:**

* **Condition Evaluation:**
  * The card only executes its action if both the **"When"** and **"And"** evaluate as true.
  * The card only executes its action if the value in the dependency column matches the provided **regex pattern**.
* **Column Calculation:**\
  If the regex pattern matches, the card performs the selected mathematical operation between the two chosen columns.
* **Result Storage:**\
  The result of the calculation is stored in the selected **result column**.

## **Setup and Configuration:**

* **Select Table:**\
  Choose the **table** where the columns will be calculated.
* **Choose Columns:**\
  Select the **first column** and **second column** that will be used in the calculation.
* **Select Operation:**\
  Choose the mathematical operation (**Add (+)**, **Subtract (-)**, **Multiply (\*)**, **Divide (/)**) to be applied between the columns.
* **Select Dependency Column:**\
  Choose the **dependency column** where the regex pattern will be applied.
* **Define Regex Pattern:**\
  Enter the **regex pattern** that the dependency column should match.
* **Select Result Column:**\
  Choose the **result column** where the calculated value will be stored.

## **Conclusion:**

The **"Calculate with Regex Dependency"** workflow card provides a powerful way to perform calculations with conditional logic based on a regex pattern. This ensures that only rows where the dependency column matches the specified pattern will undergo the specified calculation, and the result is stored in the chosen result column.

## Practical example

**When to use:** Calculate only selected table rows.

**Configuration:** Use demo table `lines` with numeric columns `quantity` and `unit_price`. Select matching rows through the dependency column and regex, multiply the numeric columns and write to `line_total`.

**Expected result and counterexample:** A selected row with `2` and `10` receives `20`. A nonmatching row must be checked separately to confirm it was not selected for calculation.

This is an illustrative configuration and expected outcome. Use fields, users and groups configured in your test organization; it is not a claim that this example was executed.


---

# 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.docbits.com/administration-and-setup/workflow/cards-overview/then/table/calculate-in.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.
