# compileFormula (@salmonui/pivot-table/engine)

> The compileFormula function of @salmonui/pivot-table/engine: Compiles a calculated field formula. fields are the source field names a reference may name (an empty list accepts any field). Throws PivotFormulaError with the offending position.

Canonical: https://salmonui.dev/docs/reference/pivot-table/engine/compileFormula

```ts
import { compileFormula } from '@salmonui/pivot-table/engine';
```

Also exported from `@salmonui/pivot-table/engine/formula`.

Entry index: https://salmonui.dev/docs/reference/pivot-table/engine (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/pivot-table/engine.md).

## Reference

Kind: function

```ts
function compileFormula(formula: string, fields?: readonly string[]): CompiledFormula;
```

Compiles a calculated field formula. `fields` are the source field names a
reference may name (an empty list accepts any field). Throws
`PivotFormulaError` with the offending position.
