Skip to content

Add formula fields to collections#274

Open
priethor wants to merge 15 commits into
mainfrom
priethor/add/formula-fields
Open

Add formula fields to collections#274
priethor wants to merge 15 commits into
mainfrom
priethor/add/formula-fields

Conversation

@priethor

@priethor priethor commented May 27, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #108.

Adds formula fields to collections. A formula is read-only in the row, but can be configured from the field menu with field("Name") or prop("Name"), arithmetic, text helpers, comparisons, if(), and a small set of date helpers, including now(). The computed value shows up in table rows, row detail, sorting, filtering, and indexed field reads when the result type supports it.

Why

Computed fields are part of the core collection workflow. They let a table express values that are derived from the row itself, like totals, labels, checks, and date offsets, without turning those values into another thing the user has to edit.

How

  • Evaluating formulas on the server so every row surface reads the same value.
  • Storing formula output in the normal row meta while blocking direct edits.
  • Resolving field references to stable field IDs so renames keep working.
  • Rejecting invalid formulas, self-references, cycles, mixed if() result types, and unsupported multi-value references before save.
  • Treating now() formulas as snapshot values that refresh when formulas are evaluated, not as live ticking values.
  • Keeping v0 scoped to same-row, single-value formulas. Multi-select, relation, rollup, regex, and collection-level operations are left for follow-ups.
  • Adding the formula editor, syntax highlighting, field/function autocomplete, and the formula language reference.

Testing Instructions

  1. Create a collection with number fields named Price and Tax.
  2. Add a formula field named Total with field("Price") + field("Tax").
  3. Confirm the row shows the computed total.
  4. Edit Price or Tax and confirm Total updates.
  5. Enter an invalid formula and confirm the inline error appears without breaking the row view.
  6. Sort and filter by Total.
  7. Open the formula reference panel and try autocomplete for fields and functions.

Screen recording

Grabacion.de.pantalla.2026-06-03.a.las.19.27.12.mov

@priethor priethor force-pushed the priethor/add/formula-fields branch 3 times, most recently from 71edfbf to dc2fa2d Compare June 1, 2026 18:07
@priethor priethor force-pushed the priethor/add/formula-fields branch from dc2fa2d to 4c91364 Compare June 2, 2026 11:37
@priethor priethor marked this pull request as ready for review June 3, 2026 17:28
@priethor priethor added type: enhancement Improvement to existing behavior. area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. labels Jun 3, 2026
@priethor priethor force-pushed the priethor/add/formula-fields branch from a8e4e2e to c15d281 Compare June 11, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add formula fields for computed values

1 participant