> ## Documentation Index
> Fetch the complete documentation index at: https://docs.allgoodhq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# What formulas are and when to use one

> Learn what an MK formula is, how it answers a question about one record, and when to use a formula instead of a built-in filter.

A **formula** is a short instruction that asks a question about one record, or works out a value from it. You type formulas into boxes marked **ƒx**. This article explains what a formula is, how MK works one out, and when to use one. You do not need to know how to code. If you have written a formula in a spreadsheet, the idea is the same.

## What a formula is

Think of a formula as a small machine. A value goes in, and a different value comes out. The value that goes in is the **before**. What the formula gives back is the **after**. The data stored on the record never changes.

Say your list has people whose emails were typed in all kinds of capitalization. This formula cleans them up:

```
$`person.email`.toLowerCase()
```

| Before (stored on the record) | After (what the formula gives back) |
| - | - |
| `'Firstname.Lastname@MyCompany.ai'` | `'firstname.lastname@mycompany.ai'` |

In every table in these articles, the quotes around text show where it starts and ends, so you can see spaces. The quotes are not part of the value.

A formula can give back two kinds of answer, depending on where you type it.

| Where you type it | What the formula must give back | What MK does with it |
| - | - | - |
| The **Filters** section of a list | True or false | Keeps the record in the list when the answer is true. Removes it when the answer is false. |
| The **Columns** section of a list | Any value, such as text or a number | Shows the value in that column for each row. |

## How MK works out a formula

Every formula follows the same five steps.

1. MK picks one record. For example, one person in your list.
2. The formula reads fields from that record. You name each field you want, such as `` $`person.title` ``.
3. MK works out the formula from the inside out, one small piece at a time. Parentheses make a piece go first.
4. The formula gives back exactly one answer.
5. MK repeats all of this for the next record.

Here is a filter worked out for two people.

```
$`person.title`.toLowerCase().includes('vp') && exists($`person.email`)
```

| Step | Ana | Ben |
| - | - | - |
| Read `person.title` | `'VP of Marketing'` | `'Director'` |
| `.toLowerCase()` changes the capitalization | `'vp of marketing'` | `'director'` |
| `.includes('vp')` asks whether the title contains "vp" | true | false |
| Read `person.email`, then `exists()` asks whether it has a value | `'ana@acme.com'` has a value, so true | No value, so false |
| `&&` asks whether both sides are true | true | false |
| Result | Ana stays in the list | Ben leaves the list |

A formula only sees the record it is working on. It never changes your data.

## Words you will see

These words come up in every formula article. The [formula reference](https://docs.allgoodhq.com/mk/formulas/reference.md) has the full list.

| Term | What it means |
| - | - |
| Record | One person or one company in MK. Each row in a list is a record. |
| Record type | A kind of data a record carries. A person can have several at once, such as the standard `person` record and a record that came from a connected system. |
| Field | One piece of data on a record type, such as `title` on `person`. |
| Read | Fetching a field's value into the formula. You write it as `` $`person.title` ``. |
| No value | Nothing is stored in the field. A field the record does not have also counts. Formulas write it as `null`. |
| Blank | No value, empty text, or text with only spaces. |
| Filled | Not blank. |

The no-data cases cause most formula surprises. [Handle blank and messy values in formulas](https://docs.allgoodhq.com/mk/formulas/handle-blank-values.md) covers them.

## When to use a formula

The built-in filter picker is the best place to start. It offers four tests: is, contains, is empty, and is set. When you add several filters, a record must pass all of them.

Use a formula when the picker cannot say what you need.

| You want to | Use |
| - | - |
| Keep records where a field equals a value | The built-in **Field** filter |
| Keep records where a field contains some text | The built-in **Field** filter |
| Keep records that have, or lack, a value | The built-in **Field** filter, with is set or is empty |
| Keep records that match this condition **or** that one | A formula filter |
| Compare a number, such as an employee count of 500 or more | A formula filter |
| Compare one field to another field | A formula filter |
| Match text after changing its capitalization or removing spaces | A formula filter |
| Show a calculated value, such as an annual figure from a monthly one | A formula column |
| Join fields or label records, such as `'Large'` or `'Small'` | A formula column |

You can use both kinds together on one list. The built-in filters and your formula filters all apply.

## What formulas cannot do

* **Look at other records.** A formula on a list reads data on the record in that row. It cannot look at other rows, and it cannot follow a person to their company.
* **Change your data.** A formula only shows or tests a value.
* **Use today's date.** Formulas have no clock, so you cannot ask for "the last 30 days." The [formulas FAQ](https://docs.allgoodhq.com/mk/formulas/faq.md) explains what you can do with dates.
* **Use anything outside the supported set.** MK rejects a formula that uses something it does not support.

## Where formulas appear in MK

You can type formulas in the **Filters** and **Columns** sections of a list. MK also uses formulas in places such as policy and motion rules. An admin usually sets those up. They all use the same language.

## Related articles

* [How formulas find your data](https://docs.allgoodhq.com/mk/formulas/how-formulas-find-your-data.md)
* [Filter a list with a formula](https://docs.allgoodhq.com/mk/formulas/filter-a-list.md)
* [Add a calculated column to a list](https://docs.allgoodhq.com/mk/formulas/add-a-calculated-column.md)
* [Formula reference: concepts, functions, and operators](https://docs.allgoodhq.com/mk/formulas/reference.md)
* [Formulas FAQ](https://docs.allgoodhq.com/mk/formulas/faq.md)

If a formula gives an answer these articles do not explain, contact allGood support. Include the formula, the record you tested it on, and the result you expected.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.