> For the complete documentation index, see [llms.txt](https://smartbooks.gitbook.io/smartbooks-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas.md).

# Formulas

Formulas turn your planning model from static input into a dynamic one: change an assumption and everything that depends on it recalculates. The following pages provide a detailed walkthrough of all available functions, complete with examples.

### Where to enter a formula

Formulas can be entered at either the Account or Subfolder level in the [Financial Accounts](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-accounts) section, or within the Manual Input screen.

* **Account or Subfolder level:** the formula applies to every planning category you have created.
* **Individual row or cell in Manual Input:** the formula only affects the planning category in which it is entered.

To use a formula, the Source for Planning of the account or subfolder must be set to **Formula**. Rows driven by a formula appear grey in the Manual Input screen and cannot be overwritten there.

{% hint style="info" %}
Not sure about the syntax? Click a cell in a Manual Input screen and then the summation sign (Σ) below the Save button to open the Formula Editor, which walks you through every function and its parameters.
{% endhint %}

### What you can reference

Formulas work across your entire reporting structure. You can reference:

* **Profit and Loss accounts**, by GL code or name.
* **Balance Sheet accounts**, by GL code or name. This is what makes a cash flow forecast possible, since Smartbooks derives cash flow from planned P\&L results and Balance Sheet movements.
* **Subfolders**, by code or name, returning the subtotal of everything underneath.
* **Metrics**, by their unique code (for example SB\_GMA%).
* **Module accounts**, through the module parameter of Account().

Cross-business dimension references are not allowed. You can refer to cost centers for total calculations, but not to populate other business dimensions.

### Available functions

| Function                                                                                                                   | What it does                                                                                             |
| -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| [Account()](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/account)                 | Retrieves the value of an account, with optional filters for year, period, cost center, view and module. |
| [PreviousPeriod()](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/previousperiod)   | The value of the same account in the previous period.                                                    |
| [PreviousQuarter()](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/previousquarter) | The value of the previous quarter.                                                                       |
| [PreviousYear()](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/previousyear)       | The value of the same period in the previous year.                                                       |
| [Movement()](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/movement)               | The change between the current and the previous period. Mostly used on Balance Sheet positions.          |
| [Max() / Min()](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/max-min)             | The highest or lowest of several values.                                                                 |
| [Iif()](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/iif)                         | Conditional logic: if the condition is true, return value A, otherwise value B.                          |

### Common patterns

**Drive one account off another** Account('4500') \* Account('SB\_GMA%')

**Carry a Balance Sheet position forward unchanged** PreviousPeriod()

**Let equity carry the planned result** PreviousPeriod() + Account('SB\_Profit\_and\_Loss')

**Make cash the balancing item** PreviousPeriod() + Movement('Liabilities') - Movement('Current Assets') - Movement('Fixed Assets')

For a full walkthrough of the last two, see [Creating a Cash Flow Forecast](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/creating-a-cash-flow-forecast).
