> ## 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.

# Add a calculated column to a list

> Add a formula column to a list to show a calculated value, such as a joined name, an annual figure, or a size label, then reorder, save, and remove it.

A **formula column** works out a value for each row in your list. Use one to join two fields into a name, turn a monthly figure into an annual one, or label records as `Large` or `Small`. The column shows the result. It does not change the data stored on the record.

This article walks you through adding a formula column, checking the values, and saving your list.

## Prerequisites

* A list open in MK, such as your people or companies list.
* Permission to edit lists, if you plan to save your changes.
* The exact names of the fields you want to use. See [How formulas find your data](https://docs.allgoodhq.com/mk/formulas/how-formulas-find-your-data.md).

## How a formula column works

MK works out your formula once for every row. The answer can be text, a number, or true or false. Whatever the formula gives back is what the row shows. If the formula gives back no value, the cell is empty.

## Steps

**1. Open your list**

Open the people or companies list you want to change. The controls appear in the panel at the side of the list.

**2. Find the Columns section**

In the panel, find the **Columns** section. A new list shows only the name column until you add more.

**3. Add a formula column**

Select **+ ƒx**. A new row appears with an empty formula box.

**4. Type your formula**

Select the box and type your formula. For example, to show a full name that handles a missing last name:

```
(($`person.firstName` ?? '') + ' ' + ($`person.lastName` ?? '')).trim()
```

**5. Apply the formula**

Press **Enter**, or select outside the box. MK applies the formula when you do either one, not while you type.

**6. Check the values**

Look at the new column. Compare a few rows with the fields they came from. Include a row with a blank field.

**7. Save your changes**

To keep the column, select **Save**. If you are working on an unsaved view, select **Save view** instead.

You will see a new column with a value in each row. The values match what the formula should give for each record.

## Try these examples

| You want to show | Formula | Works on |
| - | - | - |
| A full name, even when a piece is missing | ``(($`person.firstName` ?? '') + ' ' + ($`person.lastName` ?? '')).trim()`` | People |
| A greeting name that never shows "null" | ``!empty($`person.firstName`) ? $`person.firstName` : 'friend'`` | People |
| The domain from an email address | ``exists($`person.email`) ? $`person.email`.split('@')[1] : null`` | People |
| A monthly revenue figure, empty when revenue is missing | ``exists($`company.annualRevenue`) ? $`company.annualRevenue` / 12 : null`` | Companies |
| A size label | ``$`company.employeeCount` >= 1000 ? 'Large' : $`company.employeeCount` >= 100 ? 'Medium' : 'Small'`` | Companies |

Here is what the full-name formula gives back for four people.

| First name | Last name | After |
| - | - | - |
| `'Ann'` | `'Lee'` | `'Ann Lee'` |
| `'Ann'` | No value | `'Ann'` |
| No value | `'Lee'` | `'Lee'` |
| No value | No value | `''` (empty text) |

The size label formula checks from left to right and stops at the first true condition.

| Employee count | After |
| - | - |
| `1200` | `'Large'` |
| `250` | `'Medium'` |
| `40` | `'Small'` |

> [!NOTE]
>
> In a comparison, no value counts as `0`. A company with no employee count shows `'Small'` in the size label. To keep those rows empty, wrap the formula in a check: ``exists($`company.employeeCount`) ? ($`company.employeeCount` >= 1000 ? 'Large' : $`company.employeeCount` >= 100 ? 'Medium' : 'Small') : null``.

## Reorder or remove a column

* **To reorder,** drag the grip at the start of the row up or down. The table's columns follow right away.
* **To change a formula,** edit the text in the box, then press **Enter** or select outside the box.
* **To remove a column,** select the remove button at the end of the row.

Changes do not stay with the list until you select **Save**.

## Export your list

If your role allows exports, an export of the list uses the same columns, including formula columns. Exporting is limited to people who manage MK. If you do not see the export option, ask an admin.

## If a column looks wrong

| What you see | What to check |
| - | - |
| The column is empty on every row | Check the field names and capitalization. A wrong name reads as no value, with no warning. |
| MK shows an error message | The formula uses something MK does not support, or has a typo. Read the message. It points to the spot. |
| A name or text cell is empty when only one piece is missing | Joining with `+` gives no value when any piece has no value. Use the full-name formula above. |
| A number shows `0` instead of staying empty | In math, no value counts as `0`. Check with `exists()` first. |

For more causes and fixes, see [Formula gives a blank, wrong, or error result](https://docs.allgoodhq.com/mk/formulas/not-working.md).

## Related articles

* [What formulas are and when to use one](https://docs.allgoodhq.com/mk/formulas/what-formulas-are.md)
* [Filter a list with a formula](https://docs.allgoodhq.com/mk/formulas/filter-a-list.md)
* [Handle blank and messy values in formulas](https://docs.allgoodhq.com/mk/formulas/handle-blank-values.md)
* [Formula reference: concepts, functions, and operators](https://docs.allgoodhq.com/mk/formulas/reference.md)

If a formula column gives a result you cannot explain, contact allGood support. Include the formula, one row where the result is wrong, and the value you expected.


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