> For the complete documentation index, see [llms.txt](https://docs.syntho.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.syntho.ai/overview/get-started/syntho-bootcamp/5.-generators/calculated-columns.md).

# Calculated columns

[Calculated columns](/configure-a-data-generation-job/configure-column-settings/calculated-columns.md) allow you to define custom formulas to generate or transform data using logical, mathematical, statistical, or text-based operations. These formulas are applied after other generators like mockers or AI synthesis, ensuring that all base data is available before the calculation is performed.

#### When to use

* To clean or reformat data (e.g. trimming, date formatting)
* To apply conditional logic (e.g. gender-based name generation)
* To compute derived values from other columns (e.g. sales + tax)
* To categorize or flag data based on specific criteria

#### When not to use

* For straightforward mock data generation without dependencies
* When no conditional logic is needed
* If the column is already correctly populated or handled by simpler generators

***

#### Interactive guide: How to apply a calculated column formula

Follow the interactive guide below to apply a calculated column formula.

{% embed url="<https://www.guidejar.com/guides/f304989a-0496-4a02-8659-2762e0a157f8>" %}

#### [Syntax and structure](/configure-a-data-generation-job/configure-column-settings/calculated-columns.md#syntax)

Calculated columns follow a structured expression syntax combining functions, column references, constants, and mockers.

#### Example formulas

**1) `ROUND` — round a number to&#x20;*****N*****&#x20;decimals**

```dax
ROUND(
  [AMOUNT],
  2
)
```

* `number`: the value to round. Example: `[AMOUNT]`.
* `count`: decimal places. Example: `2` rounds to cents.

**2) `IF` — conditional logic**

```dax
IF(
  [COUNTRY] = "US",
  "domestic",
  "international"
)
```

* `test`: a condition that returns `TRUE` or `FALSE`. Example: `[COUNTRY] = "US"`.
* `then value`: returned when `test` is `TRUE`. Example: `"domestic"`.
* `otherwisevalue`: returned when `test` is `FALSE`. Example: `"international"`.

**3) `DATEADD` — shift a date by a fixed interval**

```dax
DATEADD(
  [ORDER_DATE],
  14,
  "day"
)
```

* `dates`: a date or datetime column. Example: `[ORDER_DATE]`.
* `number_of_intervals`: how many units to move. Example: `14`.
* `interval`: `"year"`, `"quarter"`, `"month"`, or `"day"`.

**4) Invoice total (combined) — arithmetic + null handling + rounding**

```dax
ROUND(
  ([AMOUNT] * (1 + IFNULL([TAX_RATE], 0))) - IFNULL([DISCOUNT], 0),
  2
)
```

Uses `IFNULL(value, replacement_value)` to guard against missing inputs.

**5) Normalized email (combined) — text functions + mocker**

```dax
SUBSTITUTE(
  CONCATENATE(
    LOWER(TRIM([FIRSTNAME])),
    ".",
    LOWER(TRIM([LASTNAME])),
    "@",
    MOCK_FREE_EMAIL_DOMAIN
  ),
  " ",
  ""
)
```

Builds an email-like string, normalizes casing, and removes spaces.

***

#### Key syntax rules

* **Column reference:** `[ColumnName]` for same-table columns
* **Functions:** `IF()`, `AND()`, `DATE()`, etc.
* **Mockers:** Use `MOCK_FIRST_NAME`, or `MOCK_CONSISTENT_FIRST_NAME` for consistent mapping
* **Operators:** `+`, `-`, `*`, `/`, `=`, `<>`, `<`, `>`
* **Constants:** Use strings `"text"`, numbers `100`, or dates `DATE(2020, 12, 31)`
* **Avoid:** Column names starting with `_`, which will cause formula errors

***

#### Using mockers in formulas

To insert mock data dynamically within formulas:

* Type `MOCK_` and choose from the autosuggest list
* Use names like `MOCK_FIRST_NAME`, `MOCK_COMPANY_EMAIL`
* For consistent mapping, use `MOCK_CONSISTENT_FIRST_NAME`, etc.

***

| Generator          | Supported data types                    |
| ------------------ | --------------------------------------- |
| Calculated Columns | Categorical, Discrete, Continuous, Date |

***

Calculated columns give you full control over how synthetic values are created or transformed. They’re ideal for applying custom logic while retaining flexibility in the data generation process.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.syntho.ai/overview/get-started/syntho-bootcamp/5.-generators/calculated-columns.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
