# Columns, variables and formulas

Set up payroll columns, use variables from HRIS, Timesheet and other sources, and write Excel-style formulas that calculate cleanly.

Source: https://support.rework.com/article/payroll-columns-formulas

Columns are the lines on your payroll and payslips: base salary, allowances, overtime, deductions, take-home pay. This article explains the three kinds of column, where formulas get their numbers from, and how to write formulas that calculate cleanly every month.

## Before you start

- You'll edit columns on a policy's **Columns** tab, so you need to be an owner of the policy or a payroll admin.
  
- Connect your data sources first, so the variables you want to use are available.
  

## Three kinds of column

| Type | Use it for | Example |
| --- | --- | --- |
| **Input** | A value that's typed in, read from a data source, or copied from another payroll. | A one-off bonus, working days from Timesheet, the advance from last month's run. |
| **Constant** | The same fixed value for everyone. | A meal allowance of 730,000. |
| **Formula** | A calculation, written like an Excel formula starting with `=`. | `=base_salary * work_day / period_days` |

Every column also has a **Tag** (**Earning**, **Tax & compliance** or **Other**) that controls how it's grouped, and a data type: number, currency, text or date. Choose **currency** for money so it prints with the right symbol and decimals. You can also decide whether a column is visible on the payslip.

## Where the numbers come from: variables

A formula can use three kinds of names:

- **Other columns**, by their **Code**. A column can only use columns placed above it.
  
- **System variables** that Payroll always provides, such as the period's days.
  
- **Source variables** from connected sources. Each one has a code you type straight into a formula.
  

To see every variable a source offers, open the **Sources** page. Each built-in adapter **(1)** lists its variable codes **(2)** with a label, data type and description **(3)**. Greyed-out variables are marked _no data source yet_, meaning nothing feeds them in your workspace for now.

![The Checkins adapter on the Sources page, with the adapter header, the variable codes such as sum\_late and sum\_minute\_late, and the Late Minutes label and type marked](https://storage.googleapis.com/reworkv3-public/success/260930/i0BZ8O1Ws1sUAZuxAwMZmtJU4TSgaDH8JNldn5FRosB6rGT2Kzeed3xuDXUmiCQa/img.bGhAOLRPDrkMjSy97ni0J2ShpHTa4GK9zlZaJMijpVe8TYuR1Ll3ftOnXnu3KUqr.png)

## Add a column

1. Open the policy's settings and go to the **Columns** tab. You'll see each column's number, name, code, source, tag and formula or value.
   
   \[IMAGE: people-ops/payroll/images/payroll-columns-formulas-02.png | The Columns tab of a policy with the column list, the search box, AI Build, Insert from template, Add Column and the locked tax rows marked\]
   
2. Click **Add Column**. To start from a ready-made set instead, use **Insert from template**.
   
3. Fill in **Name**, **Code** and an optional **Description**. The code is what other formulas use, so keep it short and stable.
   
4. Pick the **Position**, the **Tag** and the **Type**, then complete the fields for that type.
   
   \[IMAGE: people-ops/payroll/images/payroll-columns-formulas-03.png | The add column dialog for a Formula column, with Name, Code, Position, Tag, Type, the formula box and the Advanced rounding, format and conditions section marked\]
   
5. Save. The formula is checked as you save, and a column with a broken formula won't save.
   

Prefer to describe the column in words? **AI Build** drafts it for you when an AI connection is set up.

## Write formulas

Formulas work like Excel. You can use `+ - * / %`, comparisons such as `=`, `<>` and `>=`, and `AND`, `OR`, `NOT`. Handy functions include:

- **Logic**: `IF`, `IFERROR`, `ISBLANK`, `BSWITCH`
  
- **Maths**: `ROUND`, `ABS`, `INT`, `FLOOR`, `CEIL`, `MOD`, `SUM`, `AVG`, `MIN`, `MAX`, `COUNT`
  
- **Dates**: `DATE`, `YEAR`, `MONTH`, `DAY`, `TODAY`, `DATEDIF`, `EDATE`, `EOMONTH`
  
- **Brackets**: `PROGRESSIVE` and `PROGRESSIVE_TABLE` for tiered rates such as tax
  

Example: pay a 500,000 attendance bonus only when nobody was late:

`=IF(sum_late = 0, 500000, 0)`

Not sure where to start? Presets can write common patterns for you: a fixed percentage, a fixed amount, proration by days, progressive brackets, an overtime multiplier, a minimum and maximum cap, a percentage of another column, and a remainder.

### Scope, conditions and rounding

- **Scope**: most formulas are per employee. A **payroll**\-scope formula is calculated once for the whole payroll, such as a bonus pool. A payroll-wide formula can't read a per-employee column directly; use a total instead.
  
- **Conditions** (under **Advanced**): when the condition is false, the column is set to 0 (or empty for text).
  
- **Rounding, decimals and number format** (also under **Advanced**) change how the value is displayed.
  

## Good to know

- **Proration is automatic.** A formula that uses day-based variables is split across career changes in the period, so a mid-month raise is paid correctly without extra columns.
  
- **Circular formulas are blocked.** A column can't use its own code, and two columns can't depend on each other. You'll get a clear message naming the columns.
  
- **Missing source data reads as 0**, not as an error.
  
- **Red `#ERR!` cells** mean the formula itself failed, often because values in two different currencies were combined. Payslips and exports show these cells as blank.
  
- **Hand edits stick.** If you type over a calculated cell on a payroll, recalculating keeps your value and updates the columns that depend on it.
  
- On a single payroll you can edit its columns and choose **Save** (this payroll only) or **Save to template** (the policy, for future payrolls). ✨
  

## Related articles

- [Tax and compliance](https://support.rework.com/article/payroll-tax-compliance)
  
- [Connect data sources](https://support.rework.com/article/payroll-data-sources)
  
- [Payroll policies and templates](https://support.rework.com/article/payroll-policies-templates)
  
- [Payroll AI Copilot](https://support.rework.com/article/payroll-ai-copilot)
