# Formula attributes

URL: https://attio.com/help/reference/managing-your-data/attributes/formula-attributes
Breadcrumbs: [Help](https://attio.com/help) > [Reference](https://attio.com/help/reference) > [Managing your data](https://attio.com/help/reference/managing-your-data) > [Attributes](https://attio.com/help/reference/managing-your-data/attributes)

Create calculated attributes from your CRM data.

> Available on pro, enterprise plans.
>
> **Admins** can create and manage attributes.   
> **Members** can create and manage attributes with **Full access** to the relevant object or list.

Formula attributes let you derive new values from existing data in your Attio workspace.

Use them to calculate things like deal stage duration, weighted pipeline value, ICP scores, or any other value you'd otherwise track manually.

This article covers how to create and manage formula attributes. For a full list of functions and operators, see the [Formula functions library](https://attio.com/help/reference/managing-your-data/attributes/formula-functions-library). For practical examples you can copy, see [Formula attribute examples](https://attio.com/help/reference/managing-your-data/attributes/formula-attribute-examples).

## Components of a formula

Formulas can be built using a combination of:

- **Attributes**, or the values from your records that you want to calculate with. Reference an attribute by typing `{` in the formula editor.
- **Operators**, or symbols used to perform calculations and comparisons. Some examples include `+` (add), `==` (equal to), and `>` (greater than).
- **Functions**, or named actions that take inputs and return a value. Some examples include `if()`, `dateAdd()`, and `timeSpentIn()`.

For a full list of available operators and functions, see the [Formula functions library](https://attio.com/help/reference/managing-your-data/attributes/formula-functions-library).

## Create a formula attribute

To create a formula attribute, follow the same steps as [creating any other attribute](https://attio.com/help/reference/managing-your-data/attributes/create-manage-attributes#create-a-new-attribute) from the relevant object or list, selecting **Formula** as the attribute type.

![Attribute creation modal with Formula selected for Attribute Type](https://a.storyblok.com/f/234930/1680x920/7de827df7b/create-formula-attribute.png)

The output type of a formula attribute is determined automatically by the formula. A formula that returns a number produces a number attribute; a formula that returns text produces a text attribute. If you want to override the detected type, select a type from the **Output** dropdown in the formula editor.

When the output type is a number or currency, you can optionally set the number of decimal places and how values are grouped using the **Decimal places** and **Grouping** settings in the attribute panel.

### Write the formula

Click **+ Create formula** to open the formula editor. Below the formula editor, a searchable list shows all available attributes, functions, and operators. Descriptions are shown where relevant, and every item includes an example you can click to insert into your formula. For a complete reference, see the [Formula functions library](https://attio.com/help/reference/managing-your-data/attributes/formula-functions-library).

Video: https://vimeo.com/1200581229

As you type, Attio suggests matching attributes and functions. To reference an attribute, type `{` or use the **Search **below, and type the attribute name. Use the arrow keys to navigate suggestions and press **Enter** to insert one.

![Formula attribute builder showing how to add an attribute to the formula](https://a.storyblok.com/f/234930/1380x1080/e840c692ff/use-attributes-in-formula.gif)

As you build the formula, you can preview its result for a specific record. Click the record picker above the formula editor and select a record to see the value the formula would return.

Use the undo and redo arrows next to the AI input to step backward or forward through your changes, whether made manually or with the AI composer.

> **Note:** If you edit a formula in a way that changes its output type, all previously calculated values will be cleared.

### Use the AI composer

If you know what you want a formula to do but are not sure how to write it, the AI composer can generate a formula from a natural language description.

1. In the formula editor, type what you want the formula to calculate in the **Describe the formula you want Attio to create** input and press enter. For example: "Calculate the number of days this deal has been in the current stage."
2. Review the generated formula. To adjust it, type a follow-up instruction in the **Refine your formula** input and press enter. You can refine as many times as you need.
3. Click **Save** to insert the formula.

Video: https://vimeo.com/1200767121

To use the AI on a formula you've already saved, open the attribute and click on the formula to return to the AI composer.

### **Checking for errors**

Errors are highlighted in the formula editor as you type. Hover over a highlight to see the error description. Click **Fix** to have AI attempt to resolve the error automatically.

![](https://a.storyblok.com/f/234930/996x528/a30ec448ef/formula-error.png)

### Reference one formula in another

You can reference an existing formula attribute inside a new formula up to three formulas deep, letting you build on computed values without duplicating logic.

For example, if you have a formula attribute called "Days in stage," you can reference it in a second formula the same way you would reference any other attribute, by typing `{` and selecting it from the list.

## How formulas calculate

Attio keeps formula values up to date automatically and follows consistent rules when data is missing.

### When formulas recalculate

Formula attributes calculate values for all records automatically when you first create them. If you edit the formula, Attio recalculates all values using the updated formula. Formula values also recalculate automatically whenever any referenced value changes.

Formulas that use `now()` or `today()` also recalculate once a day, around midnight UTC.

### How empty values are handled

When an attribute has no value, formulas treat it as a special empty value called `null`. A few rules govern how `null` behaves:

- If a formula returns `null`, it clears the attribute value for that record.
- If any input to a function is `null`, the function usually returns `null` as well. For example, `{Company.MRR} * 12` returns an empty value when `{Company.MRR}` is empty.

To handle empty values, you can:

- **Set a fallback with the **`??`** operator:** `{Company.MRR} ?? 0` returns `0` when MRR is empty.
- **Check for empty values directly:** `{Company.MRR} == null` returns true when MRR has no value.

Some functions handle `null` differently:

- **Logical functions** treat `null` as `false`.
- `contains()`** and **`count()` treat `null` as empty, returning `false` and `0` respectively.

## Related resources

- See the [Formula functions library](https://attio.com/help/reference/managing-your-data/attributes/formula-functions-library) for a full list of available functions and operators with examples.
- For real examples you can adapt to your own workspace, see [Formula attribute examples](https://attio.com/help/reference/managing-your-data/attributes/formula-attribute-examples).
- To learn more about attributes in general, see [Create and manage attributes](https://attio.com/help/reference/managing-your-data/attributes/create-manage-attributes).

## FAQ

### What happens to my formula attributes if I downgrade to Free or Plus?

If your workspace downgrades to the Free or Plus plan, existing formula attributes will stop recalculating and their values will be frozen. Formula attributes will not be visible in table views until the workspace upgrades to the Pro or Enterprise plan.

### Can I write custom code or JavaScript in a formula?

No. Formula attributes use Attio's formula language, which includes a defined set of functions and operators. Custom code execution is not supported.

### Do formula attributes use workspace credits?

No. Formula attributes do not require workspace credits, including use of the AI composer.

### If I rename an attribute option, will my formula still work?

It depends on how you referenced the option. If you selected the option from the suggestions in the formula editor, the formula links to the option itself and continues to work after a rename. If you typed the option as text in quotes, it is treated as a fixed string and will not update if the option is renamed.
