← Wed, Nov 4 digest

Adding Window Functions to a Spreadsheet

read article ↗ hn thread ↗

Grist adds database-style window functions like PREVIOUS and ordered lookups to its spreadsheet formulas, eliminating the fragility of traditional row-reference running totals.

summary is enough The post clearly explains how built-in ordered lookups solve spreadsheet formula fragility, but the full text is primarily a product feature walkthrough.

summary

Traditional spreadsheets break running totals and approximate matches when rows are inserted or deleted because formulas rely on brittle cell references. Grist addresses this by introducing declarative window functions like PREVIOUS, NEXT, and ordered lookups directly into its Python-backed formulas. These functions use binary search under the hood, maintaining performance on large datasets without manual cell management. The result is a robust alternative that keeps calculations correct regardless of row sorting or edits.

key points

  1. Traditional spreadsheets break running totals when inserting rows because references point to static cell coordinates like the cell above.
  2. Grist introduces PREVIOUS and ordered lookups to compute running balances and nearest-match tiers based on sorting rules inside the formula rather than screen positions.
  3. Ordered lookups use binary search, avoiding slow O(N) table scans and maintaining performance on datasets with tens of thousands of rows.

who should read it

Spreadsheet power users and developers looking for alternatives to traditional cell-reference fragility.

discussion positive

consensus

Commenters generally appreciate attempts to modernize spreadsheets with code-friendly syntax or native programming features, though many pivot to discussing alternative spreadsheet tools.

pushback

Several users criticize Grist's syntax as an awkward mix of uppercase spreadsheet macros and Python object notation, finding it overly verbose or unintuitive.

best comment by shevy-java ↗

The syntax is so archaic ... it really is anything but a thing of beauty.

prev_balance = PREVIOUS(rec, order_by="Date").Running_Balance or 0 prev_balance + $Amount

It's such a strange mix-up of stuff. PREVIOUS() is a macro or looks like one, right? But it is a function call assumingly. But then what's with .Running_Balance? Guess that also ties into a function. But why use different syntax for essentially the same thing? It seems rather weird to write code like that. What would the python variant be like? Or a DSL?

The syntax strangeness continues:

rates = …

It provides specific critiques of Grist's hybrid syntax mixing uppercase macro-style function calls with Python object properties.

Generated by an LLM from the article and thread. Check the sources before relying on it.