# Formula field

Formulas let you transform and combine existing fields into a new Formula field. For example, you can:

* Concatenate `First name` and `Last name` fields into a `Full name` Formula field.
* Multiply `Price` and `Units` field to get the result in the `Revenue` Formula field.

The field will show only in your Stacker app, and won't show up in your Airtable base.

## Create a formula field <a href="#h_01h8yqs1mvh1a00mbqr3dps3b6" id="h_01h8yqs1mvh1a00mbqr3dps3b6"></a>

1. Go to **Manage Fields and data**
2. Select the table and select **Fields**
3. Click **Add field**
4. Give your field a name
5. Select the field type: **Formula**
6. Type in your formula and click **Save**

## ![formula field creation.gif](https://support.stackerhq.com/hc/article_attachments/19995070624787) <a href="#h_01hd76jgvqwktwe9m13441wt2h" id="h_01hd76jgvqwktwe9m13441wt2h"></a>

## Fields in formulas <a href="#h_01fzgb5yyad3t8s4jeehnzxe4q" id="h_01fzgb5yyad3t8s4jeehnzxe4q"></a>

To use a field in a formula, the field needs to be in the table where you're creating the formula field. It also needs to be one of the following data types:

* Text
* Long Text
* Number
* Checkbox
* URL
* Single Select Dropdown
* Percentage
* Currency
* Rich Text
* Date
* Date and Time
* Multiple Select Dropdown

To use a field in a formula, you will need to wrap it in curly brackets. For example, {Price}. If you type in the opening curly bracket, we will suggest all available fields.

![Screenshot\_2022-03-31\_at\_16.06.25.png](https://support.stackerhq.com/hc/article_attachments/5180888285715)

## List of formulas <a href="#h_01h8yqs1mvyfpvqd3sypncrzk8" id="h_01h8yqs1mvyfpvqd3sypncrzk8"></a>

Functions work with any [valid field data types](#h_01FZGB5YYAD3T8S4JEEHNZXE4Q), while operators work only on number fields. If you use an operator for a non-number field, we will try to convert it into a number. If we can't, you'll see an error message.

#### SUM <a href="#h_01h8yqs1mv1av5eqpjgjyg1pet" id="h_01h8yqs1mv1av5eqpjgjyg1pet"></a>

Returns the sum of two or more numbers.

**Example:**

`SUM({Sold},{Not sold})`

or

`{Sold} + {Not sold}`

#### &#x20;<a href="#h_01h8yqs1mvsqvrj59rn5mr2206" id="h_01h8yqs1mvsqvrj59rn5mr2206"></a>

#### SUBTRACT <a href="#h_01h8yqs1mvedmaz39hgbcfbmgk" id="h_01h8yqs1mvedmaz39hgbcfbmgk"></a>

Returns the difference of two numbers.

**Example:**

`{Total stock} - {Sold stock}`

#### &#x20;<a href="#h_01h8yqs1mv622f36phh4ath48f" id="h_01h8yqs1mv622f36phh4ath48f"></a>

#### MULTIPLY <a href="#h_01h8yqs1mvmw45p760tb6c2jwn" id="h_01h8yqs1mvmw45p760tb6c2jwn"></a>

Returns the product of two numbers.

**Example:**

`{Sold} * {Price}`

#### &#x20;<a href="#h_01h8yqs1mva7twww7ffxh8xj3z" id="h_01h8yqs1mva7twww7ffxh8xj3z"></a>

#### DIVIDE <a href="#h_01h8yqs1mvnjwt88abhwa5n6rq" id="h_01h8yqs1mvnjwt88abhwa5n6rq"></a>

Returns one number divided by another.

**Example:**

`{Total sold} / {Price}`

#### &#x20;<a href="#h_01h8yqs1mv4jt9jfxa7jgww1mw" id="h_01h8yqs1mv4jt9jfxa7jgww1mw"></a>

#### AVERAGE <a href="#h_01h8yqs1mvagvm42h74g6pstbz" id="h_01h8yqs1mvagvm42h74g6pstbz"></a>

Returns the average of the values in two or more fields.

**Example:**

`AVERAGE({Sold},{Not sold})`

#### &#x20;<a href="#h_01h8yqs1mv7rcrf034meb770nz" id="h_01h8yqs1mv7rcrf034meb770nz"></a>

#### NOT EQUAL TO <a href="#h_01h8yqs1mv3jkr2stbv452rfev" id="h_01h8yqs1mv3jkr2stbv452rfev"></a>

Check if one value is not equal to another.

**Example:**

`1!=2 =>True` (represented as a checked checkbox)

#### &#x20;<a href="#h_01h8yqs1mv82hrngywxcqqz7jb" id="h_01h8yqs1mv82hrngywxcqqz7jb"></a>

#### EQUAL TO <a href="#h_01h8yqs1mvgjr2dkywe9v53cfn" id="h_01h8yqs1mvgjr2dkywe9v53cfn"></a>

Compare if one value is equal to another value.

**Example:**

`1=1 =>True` (represented as an empty checkbox)

#### &#x20;<a href="#h_01h8yqs1mv58hy2q2754mfe94k" id="h_01h8yqs1mv58hy2q2754mfe94k"></a>

#### GREATER THAN <a href="#h_01h8yqs1mv6rxgq2ht3t43ks2m" id="h_01h8yqs1mv6rxgq2ht3t43ks2m"></a>

Compare if one value is greater than another value.

**Example:**

`1>5 =>False` (represented as an empty checkbox)

#### &#x20;<a href="#h_01h8yqs1mvhq1qqe1b24ww8cbk" id="h_01h8yqs1mvhq1qqe1b24ww8cbk"></a>

#### GREATER THAN OR EQUAL TO <a href="#h_01h8yqs1mv64cwmydh8hzymnvh" id="h_01h8yqs1mv64cwmydh8hzymnvh"></a>

Compare if one value is greater than or equal to another value.

**Example:**

`2>=2 =>True` (represented as a checked checkbox)

#### &#x20;<a href="#h_01h8yqs1mv9vqynhefbnf68xqt" id="h_01h8yqs1mv9vqynhefbnf68xqt"></a>

#### LESS THAN <a href="#h_01h8yqs1mv7252yh5gb78qb5a7" id="h_01h8yqs1mv7252yh5gb78qb5a7"></a>

Compare if one value is less than another value.

**Example:**

`5<1 =>False` (represented as an empty checkbox)

#### &#x20;<a href="#h_01h8yqs1mvwnn4hp89jbrr6f71" id="h_01h8yqs1mvwnn4hp89jbrr6f71"></a>

#### LESS THAN OR EQUAL TO <a href="#h_01h8yqs1mv836r7z42k4rgc3bf" id="h_01h8yqs1mv836r7z42k4rgc3bf"></a>

Compare if one value is less than another value.

**Example:**

`2<=2 =>True` (represented as a checked checkbox)

#### &#x20;<a href="#h_01h8yqs1mv58gt50k9a85rqq3m" id="h_01h8yqs1mv58gt50k9a85rqq3m"></a>

#### CONCAT( , ) or & <a href="#h_01h8yqs1mvxhfjr3rjjbh79rvy" id="h_01h8yqs1mvxhfjr3rjjbh79rvy"></a>

Concatenate two values.

**Example:**

`CONCAT("Hello ", {Fullname}, " !")`

or

`"Hello " & {Fullname} & " !"`

#### &#x20;<a href="#h_01h8yqs1mw7a0cjbbxf90y00aw" id="h_01h8yqs1mw7a0cjbbxf90y00aw"></a>

#### IF (statement, Action A, Action B) <a href="#h_01h8yqs1mw90jtd0zsm0wcbvbh" id="h_01h8yqs1mw90jtd0zsm0wcbvbh"></a>

Check whether the statement is true. If it is true, then do action A, if it is false do action B.

**Example:**

`IF({UserId}, "https://dashboard.com/" + {UserId}, "")`

#### &#x20;<a href="#h_01h8yqs1mw0kh521nc2rjppkjw" id="h_01h8yqs1mw0kh521nc2rjppkjw"></a>

#### AND( ) <a href="#h_01h8yqs1mwq7n19dn46gefat5a" id="h_01h8yqs1mwq7n19dn46gefat5a"></a>

Returns true if all the arguments are true, returns false otherwise.

**Example:**

`AND({Field 1}),{Field 2})`

or

`{Field 1} AND {Field 2}`

#### &#x20;<a href="#h_01h8yqs1mwxxcvy3gz0rt2wngf" id="h_01h8yqs1mwxxcvy3gz0rt2wngf"></a>

#### OR( ) <a href="#h_01h8yqs1mw7vyvgynb2cyafqv1" id="h_01h8yqs1mw7vyvgynb2cyafqv1"></a>

Returns true id any one of the argument is true.

**Example:**

`OR({Field 1}),{Field 2})`

or

`{Field 1} OR {Field 2}`

#### &#x20;<a href="#h_01h8yqs1mwjxg8cvnanm2faa7b" id="h_01h8yqs1mwjxg8cvnanm2faa7b"></a>

#### NOT( ) <a href="#h_01h8yqs1mw5yyfzstdb258hxj4" id="h_01h8yqs1mw5yyfzstdb258hxj4"></a>

Reverse a true to false.

**Example:**

`NOT(a<b)` Returns the same as `a>=b`

#### &#x20;<a href="#h_01h8yqs1mw07r27habvvtshebk" id="h_01h8yqs1mw07r27habvvtshebk"></a>

#### LEN <a href="#h_01h8yqs1mwrt9cgy4nstcn32fy" id="h_01h8yqs1mwrt9cgy4nstcn32fy"></a>

Returns the length of a string.

**Example:**

`LEN("Hello World") =>11`

#### &#x20;<a href="#h_01h8yqs1mwdvg0gxywdqrjddfy" id="h_01h8yqs1mwdvg0gxywdqrjddfy"></a>

#### REGEX\_MATCH( ) <a href="#h_01h8yqs1mwp979jed96rzk7c46" id="h_01h8yqs1mwp979jed96rzk7c46"></a>

Returns whether the input text matches a regular expression.

**Example:**

`REGEX_MATCH("Good Morning","Good.Morning" =>True` (Represented as a checked checkbox)

#### &#x20;<a href="#h_01h8yqs1mwbpraeg0sct97pjbc" id="h_01h8yqs1mwbpraeg0sct97pjbc"></a>

#### REGEX\_REPLACE( ) <a href="#h_01h8yqs1mwefdt37cr03k1ykcx" id="h_01h8yqs1mwefdt37cr03k1ykcx"></a>

Substitutes all matching substrings with a replacement string value.

**Example:**

`REGEX_REPLACE("Good Morning","M*",""=>"Good"`

#### &#x20;<a href="#h_01h8yqs1mwg33gxkvz7sth5san" id="h_01h8yqs1mwg33gxkvz7sth5san"></a>

#### REGEX\_EXTRACT( ) <a href="#h_01h8yqs1mwd2gj80sz5gf7sh82" id="h_01h8yqs1mwd2gj80sz5gf7sh82"></a>

Returns the first substring that matches a regular expression.

**Example:**

`REGEX_EXTRACT("Good Morning","M*",""=>"Morning"`

#### &#x20;<a href="#h_01h8yqs1mwzpedvr557xbdjgre" id="h_01h8yqs1mwzpedvr557xbdjgre"></a>

#### TRIM( ) <a href="#h_01h8yqs1mwsmegp0qw00rdpz8s" id="h_01h8yqs1mwsmegp0qw00rdpz8s"></a>

Removes the whitespace at the beginning and end of string.

**Example:**

`TRIM(" Hello ") =>"Hello"`

#### &#x20;<a href="#h_01h8yqs1mw708n7396131t00hw" id="h_01h8yqs1mw708n7396131t00hw"></a>

#### UPPER( ) <a href="#h_01h8yqs1mwzfz36m84wj6rhp0y" id="h_01h8yqs1mwzfz36m84wj6rhp0y"></a>

Makes string uppercase.

**Example:**

`UPPER("Hello") =>"HELLO"`

#### &#x20;<a href="#h_01h8yqs1mwnfyrp2hg44909fkn" id="h_01h8yqs1mwnfyrp2hg44909fkn"></a>

#### LOWER( ) <a href="#h_01h8yqs1mw0675r79cc52vjfjn" id="h_01h8yqs1mw0675r79cc52vjfjn"></a>

Makes string lowercase.

**Example:**

`LOWER("Hello") =>"hello"`

#### &#x20;<a href="#h_01h8yqs1mwsap30q7wf8q08q96" id="h_01h8yqs1mwsap30q7wf8q08q96"></a>

#### RIGHT( ) <a href="#h_01h8yqs1mw1e4ndp8mq3qrqegx" id="h_01h8yqs1mw1e4ndp8mq3qrqegx"></a>

Extract how many characters from the end of the string. Accepts string for first arg, number for second.

**Example:**

`RIGHT("Hello",2) =>"lo"`

#### &#x20;<a href="#h_01h8yqs1mw8hc48tnpv8gba76h" id="h_01h8yqs1mw8hc48tnpv8gba76h"></a>

#### IS\_SAME( ) <a href="#h_01h8yqs1mwpbp6qyy0v4b20474" id="h_01h8yqs1mwpbp6qyy0v4b20474"></a>

Compares two dates up to a unit and determines whether they are identical. Returns true or false.

**Example:**

`IS_SAME({date 1},{date 2}, 'unit')`

current acceptable units are:

`'exact'`(matches all units)

`'year'`, `'month'`, `'day'`

#### &#x20;<a href="#h_01h8yqs1mwtv6w7c51xqyqrf4k" id="h_01h8yqs1mwtv6w7c51xqyqrf4k"></a>

#### IS\_BEFORE( ) <a href="#h_01h8yqs1mw4jqtyjv6e4vjh92c" id="h_01h8yqs1mw4jqtyjv6e4vjh92c"></a>

Determines if \[date1] is earlier than \[date2]. Returns 1 is yes, 0 if no.

**Example:**

`IS_BEFORE({date 1},{date 2})`

#### &#x20;<a href="#h_01h8yqs1mw16f4ra6d0g5dh8ew" id="h_01h8yqs1mw16f4ra6d0g5dh8ew"></a>

#### IS\_AFTER( ) <a href="#h_01h8yqs1mww17c4ev2rt9tv93z" id="h_01h8yqs1mww17c4ev2rt9tv93z"></a>

Determines if \[date1] is later than \[date2]. Returns 1 is yes, 0 if no.

**Example:**

`IS_AFTER({date 1},{date 2})`

#### &#x20;<a href="#h_01h8yqs1mwta5q353heda486zq" id="h_01h8yqs1mwta5q353heda486zq"></a>

#### YEAR( ) <a href="#h_01h8yqs1mw2x3ys8nsq0cn20gv" id="h_01h8yqs1mw2x3ys8nsq0cn20gv"></a>

Returns the four-digit year of datetime.

**Example:**

`YEAR({Date},[timezone])`

#### &#x20;<a href="#h_01h8yqs1mwjpe33z6wgsb57m3d" id="h_01h8yqs1mwjpe33z6wgsb57m3d"></a>

#### MONTH( ) <a href="#h_01h8yqs1mwm7t0cjxs7rn974cq" id="h_01h8yqs1mwm7t0cjxs7rn974cq"></a>

Returns the month of a datetime as a number between 1 (January) and 12 (Decemeber).

**Example:**

`MONTH({Date},[timezone])`

#### &#x20;<a href="#h_01h8yqs1mwmzj09dr7wznx4vfw" id="h_01h8yqs1mwmzj09dr7wznx4vfw"></a>

#### DAY( ) <a href="#h_01h8yqs1mw6q5z2axrenq6kf1b" id="h_01h8yqs1mw6q5z2axrenq6kf1b"></a>

Returns the day of a month of a datetimein the form of a number between 1-31.

**Example:**

`DAY({Date},[timezone])`

#### &#x20;<a href="#h_01h8yqs1mws4wy9s6vx03k5b5v" id="h_01h8yqs1mws4wy9s6vx03k5b5v"></a>

#### HOUR( ) <a href="#h_01h8yqs1mwfrrp4fpaewnx8ngt" id="h_01h8yqs1mwfrrp4fpaewnx8ngt"></a>

Returns the hour of a datetime as a number between 0 (12.00am) and 23 (11.00pm).

**Example:**

`HOUR({Date},[timezone])`

#### &#x20;<a href="#h_01h8yqs1mwc92gx9nmnfrx0637" id="h_01h8yqs1mwc92gx9nmnfrx0637"></a>

#### MINUTE( ) <a href="#h_01h8yqs1mwrb20k84fzt6ft1rt" id="h_01h8yqs1mwrb20k84fzt6ft1rt"></a>

Returns the minute if datetime as a number.

**Example:**

`MINUTE({Date},[timezone])`

#### &#x20;<a href="#h_01h8yqs1mwdsrhxt0dasxpeqck" id="h_01h8yqs1mwdsrhxt0dasxpeqck"></a>

#### LEFT( ) <a href="#h_01h8yqs1mwhk5g880gxvt7dsp0" id="h_01h8yqs1mwhk5g880gxvt7dsp0"></a>

Extract how many characters from the beginning of the string. Accepts the string for first arg, number for second.

**Example:**

`LEFT("Hello",2) =>"He"`

#### &#x20;<a href="#h_01h8yqs1mwbwf9qbvx6wtza5ds" id="h_01h8yqs1mwbwf9qbvx6wtza5ds"></a>

#### DATEDIF( ) <a href="#h_01h8yqs1mwq0bnp69jz4wbkfym" id="h_01h8yqs1mwq0bnp69jz4wbkfym"></a>

Returns the difference between datetimes in the unit specified.

Unit accepts:

`'year'`,`'month'`,`'week'`,`'day'`,`'hour'`,`'minute'`

**Example:**

`DATEDIF([date1],[date2],"units")`

#### &#x20;<a href="#h_01h8yqs1mw04vdytxek605xpza" id="h_01h8yqs1mw04vdytxek605xpza"></a>

#### MIN( ) <a href="#h_01h8yqs1mw12svhs9nrtqbzhpc" id="h_01h8yqs1mw12svhs9nrtqbzhpc"></a>

Returns the item with the lowest value.

**Example:**

`MIN(number 1, number 2, number 3...)`

#### &#x20;<a href="#h_01h8yqs1mxvqzh90nqat2ts69c" id="h_01h8yqs1mxvqzh90nqat2ts69c"></a>

#### MAX( ) <a href="#h_01h8yqs1mxe4tegdx853e7jam5" id="h_01h8yqs1mxe4tegdx853e7jam5"></a>

Returns the largest item between two or more parameters.

**Example:**

`MAX(number 1, number 2, number 3...)`

#### &#x20;<a href="#h_01h8yqs1mxew2tg0ykpwwz83hv" id="h_01h8yqs1mxew2tg0ykpwwz83hv"></a>

#### ABS(number) <a href="#h_01h8yqs1mxcf70zc24g4ehkadj" id="h_01h8yqs1mxcf70zc24g4ehkadj"></a>

Returns the absolute value.

**Example:**

`ABS(-5)`

#### &#x20;<a href="#h_01h8yqs1mxrvj9r31s25jjh7et" id="h_01h8yqs1mxrvj9r31s25jjh7et"></a>

#### DATEADD( ) <a href="#h_01h8yqs1mxacf7d7zbprtef7dt" id="h_01h8yqs1mxacf7d7zbprtef7dt"></a>

Adds a time/date interval to a date and then returns the date.

**Example:**

`DATEADD([date],[#],"units")` (accepts years, months, weeks and days as well as singular counter-parts)

#### &#x20;<a href="#h_01h8yqs1mxf7hd1dn7bjw3gxqg" id="h_01h8yqs1mxf7hd1dn7bjw3gxqg"></a>

#### TODAY(timezone) <a href="#h_01h8yqs1mxmx1bbf8wahtr04wb" id="h_01h8yqs1mxmx1bbf8wahtr04wb"></a>

Returns the current date, but not the current time.

#### &#x20;<a href="#h_01h8yqs1mxn5nwy1rx2errdzkt" id="h_01h8yqs1mxn5nwy1rx2errdzkt"></a>

#### NOW( ) <a href="#h_01h8yqs1mxzcmknkerwrz3bmvj" id="h_01h8yqs1mxzcmknkerwrz3bmvj"></a>

Returns the current date and time.

#### &#x20;<a href="#h_01h8yqs1mx9src79rksgwr51mg" id="h_01h8yqs1mx9src79rksgwr51mg"></a>

#### ROUND( ) <a href="#h_01h8yqs1mxxs84ae8ep2fnd7d1" id="h_01h8yqs1mxxs84ae8ep2fnd7d1"></a>

Rounds to a number of decimal places as specified by precision e.g "0", "1", etc.

**Example:**

`ROUND({Unit Price},0)`

#### ROUNDUP( ) <a href="#h_01h8yqs1mxbz9536spr07dkj8f" id="h_01h8yqs1mxbz9536spr07dkj8f"></a>

Rounds the value to the number of decimal places given by "precision" always rounding up. e.g "0", "1", etc.

**Example:**

`ROUNDUP({Unit Price},0)`

#### &#x20;<a href="#h_01h8yqs1mx56n0hv1n4cbpmnep" id="h_01h8yqs1mx56n0hv1n4cbpmnep"></a>

#### VALUE(string) <a href="#h_01h8yqs1mx4gj1rfhj36z85mvs" id="h_01h8yqs1mx4gj1rfhj36z85mvs"></a>

Coverts text string to a number.

**Example:**

`VALUE({Quoted Price})`

#### &#x20;<a href="#h_01h8yqs1mx9h2yvkxeky197xkn" id="h_01h8yqs1mx9h2yvkxeky197xkn"></a>

#### INT( ) <a href="#h_01h8yqs1mxhcpn7gjw7m3qfw0j" id="h_01h8yqs1mxhcpn7gjw7m3qfw0j"></a>

Returns the greatest integer that is less than or equal to the number.

**Example:**

`INT({Unit Price})`

## Error messages <a href="#h_01h8yqs1mx9cwey2acmq73gm16" id="h_01h8yqs1mx9cwey2acmq73gm16"></a>

If a formula is invalid, you will see an error message that might help you understand what went wrong.

| Error                                                                     | Meaning                                                                        |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| `Missing formula function` or `Unexpected formula function`               | Means that you were very creative, but we don't have the formula function yet. |
| `Function only works with field_type but field is a another_field_type`   | Shows when using a field with an incompatible field type.                      |
| `In an IF function, field_name and field_name_2 must be of similar types` | Shows in an IF function when the Action A and Action B are different types.    |
| `Missing keys in formula 'IF' function: else`                             | Means that there is a missing else (Action B) in the IF function.              |


---

# Agent Instructions: 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:

```
GET https://docs.stackerhq.com/stacker-classic/data/formula-field.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
