29 points reedciccio 2 hours ago 19 comments
shevy-java 2 hours ago | parent
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 = Rates.lookupRecords(Person=$Person, order_by="Rate_Start")
rates.find.le($Date).Hourly_Rate
Does that really convey most easily what is wanted? It seems needlessly
verbose. Why would it require both $Person and $Date? Should that not
be easier to figure out in its own right? Is that efficient?People need to remember that mentally, unless they use AI.
paulfitz 2 hours ago | parent
PREVIOUS returns a record, then .Running_Balance pulls out one field of it.
whizzter 2 hours ago | parent
librasteve 1 hour ago | parent
dsagal 23 minutes ago | parent
E.g. UPPER($A) is just a function that calls $A.upper(). And $A is just syntactic sugar over rec.A.
PREVIOUS() is only special in that it automatically creates an index, which is important for efficiency. But generally you can look up a set of records and write multi-line Python code to do whatever you want with it and return a value. And it all runs in a sandbox with no access to anything except this document's data.
chii 2 hours ago | parent
I reckon it makes more sense to return a table, and then have an index lookup in that table: e.g., index(PREVIOUS(blah_blah), column). Then you can also use an indirection to choose which column from another cell if desired.
This is how google finance in sheets returns some data (like exchange rates, iirc).
whizzter 2 hours ago | parent
The root issue is that there's almost 50 years of spreadsheet syntax to consider and not colliding with.
librasteve 1 hour ago | parent
librasteve 1 hour ago | parent
All feedback good and bad v welcome.
WillAdams 1 hour ago | parent
librasteve 1 hour ago | parent
oh and omasheet is Rust and uses Polars so I am working with that rather than NumPy SciPy
WillAdams 38 minutes ago | parent
seemaze 1 hour ago | parent
pstuart 38 minutes ago | parent
halo 1 hour ago | parent
mallahan 27 minutes ago | parent
quaintdev 26 minutes ago | parent