Formulas

Bases formula fields calculate record values from table data. UniverBasesPlugin registers its formula-engine dependency automatically.

Register formula support

TypeScript
import { UniverBasesPlugin } from '@univerjs-pro/bases'import { UniverBasesUIPlugin } from '@univerjs-pro/bases-ui'univer.registerPlugin(UniverBasesPlugin)univer.registerPlugin(UniverBasesUIPlugin)

Create a formula field

TypeScript
const formulaTableName = table.getFormulaName()const total = table.addField('Total', univerAPI.Enum.BaseFieldType.Formula, {  field: {    config: {      formula: `=SUM(${formulaTableName}[[#This Row],[Price]],${formulaTableName}[[#This Row],[Tax]])`,    },  },  externalReferences: [],})

externalReferences is required for every formula-field write. Use [] only for formulas that reference fields in the host Base. For cross-unit formulas, use buildReference and pass every stable source binding in this array.

Notes

  • Formula fields are derived values; avoid writing directly to formula cells from application code.
  • Formula expressions use structured field references such as Table[[#This Row],[Price]].
  • Recalculate formulas after importing large snapshots before exposing results to users.

How is this guide?

© 2026 DreamNum Co., Ltd.