Closed roman-balzer closed 4 months ago
What kind of operations are you thinking? Something like Excel?
=SUM(B4:E4)
An Excel-like operation is pretty simple and won't need a library. You would just need to handle some basics operations sum
, max
, min
. I have already made utility functions for these for the calculation row.
More complex function support might merit a library. It doesn't seem like that is what people are asking for though. I'm open to thoughts.
I thought about more complex Operations.
+
, -
, *
and /
(maybe **
)sum
, avg
, max
, min
, ...concat
, replace
and interpolate
and
, or
, not
and if/else
Thou, this would require a lib, or an implementation of a custom syntax.
If you're looking for a pretty powerful library to manipulate data check JSONata: https://jsonata.org It has pretty much everything needed for these type of calculations and that would make formula cells very powerful !
If you're looking for a pretty powerful library to manipulate data check JSONata: https://jsonata.org It has pretty much everything needed for these type of calculations and that would make formula cells very powerful !
Already looked into JSONata. Thou first of all we don't really have complex JSON structures, but rather simple "key value pairs". Also it's imho quite complex and too powerful, for a simple formula cell. I wouldn't want that they user should have to lookup the docs of JSONata to be able to use the formula cell, especially if they don't have a "coding background".
I'd love to simply have the formulas be JS — or at least as close as possible — rather than yet another special query language. (Beyond that, can take inspiration from Coda?) I'd love to be able to call out to external JS libraries too. Granted, potentially this could be non-performant, since special optimizations can't be made for opaque code (unlike e.g. max
, min
, etc.). However, it means that you won't always be playing whack-a-mole to try to implement user requests for each new function.
Sadly, I won't be finishing this PR, since I don't really find much time to think about a formula syntax, or to use an existing solution like JSONata. And also to be honest, since I don't really use Loom anymore, it really dropped from my priority list.
If someone want to continue this PR, the changes on my branch contain the logic to access the data from other table cells. What's left to implement is a syntax for the user to use these values.
Hey, i'm currently working on a Formula Cell. Draft PR for now, since this is the first iteration.
Open issues regarding this feature: #406, #566, #565 and #455
I'm still not sure how to implement the formula syntax currently. Would be great if we could use a library as function parser, where I could fill in the variable with cell data, but I'll have to look into that. If there are some good libs tell me, so I can look into it :)