> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/recommendations-and-merchandising/concepts/datasets-and-fields/formula-fields-ia.md).

# Formula Fields (IA)

Create custom fields directly in your catalog - no need to edit your source file. Use formulas to calculate values, combine fields, or create new attributes, with help from AI.

### What you can do ?

You can&#x20;

* **Compute values** (e.g. margin, discount, VAT…),&#x20;
* **Define fields** (e.g. brand + product name)
* **Create conditions** (e.g. flag out-of-stock items)&#x20;
* **Normalize data** (e.g. round prices, format text)

### How to use it Fields ?

{% stepper %}
{% step %}

#### Go to Catalog > Fields

* Click **➕ Add Formula Field**
* Choose a name and a field type (number, string, boolean, date)
  {% endstep %}

{% step %}

#### Write your formula

You can either:

* Type it manually using field names like `{{price}}`, `{{brand}}`, etc.
* Or click **✨ Ask AI** and describe what you want in plain English or French.

**Examples**

```
({{price}} - {{cost_price}}) / {{price}}      → margin
CONCAT({{brand}}, " ", {{name}})             → combined title
IF({{stock}} == 0, "OUT", "IN")              → stock flag
```

{% endstep %}

{% step %}

#### Check your result

* A preview shows up to 10 sample rows
* Errors appear in red (wrong field, missing parenthesis, etc.)
  {% endstep %}

{% step %}

#### Save

Once validated, your new field is added to your catalog and updated automatically during each sync
{% endstep %}
{% endstepper %}

### How to use AI Fields Assistant ?

Describe what you want, for example :

```
Prompt: Create a margin percentage between price and cost price.
AI: ({{price}} - {{cost_price}}) / {{price}}
```

Another example:&#x20;

```
Prompt: Why is my formula not in % unit ?
```

The AI will explain and fix it.

### Best practices

* Keep field names consistent (`price`, `cost_price`, etc.)
* Always use preview before saving
* Use `ROUND()` for numeric fields
* Use quotes for text values (“OUT”, “IN”)
* Avoid spaces or special characters in field names

### Notes & limits

* Works only with fields in your current catalog
* No cross-table formulas yet
* Up to 200 characters per formula
* Available for **Editor** and **Admin** roles only

### Example use cases

| Goal               | Formula                                    | Result         |
| ------------------ | ------------------------------------------ | -------------- |
| Calculate margin   | `({{price}} - {{cost_price}}) / {{price}}` | 0.25           |
| Label stock status | `IF({{stock}} == 0, "OUT", "IN")`          | “IN”           |
| Build SEO title    | `CONCAT({{brand}}, " ", {{name}})`         | “Nike Air Max” |
| Round price        | `ROUND({{price}}, 2)`                      | 49.99          |


---

# 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.abtasty.com/recommendations-and-merchandising/concepts/datasets-and-fields/formula-fields-ia.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.
