Derived Relations (Formulas)

This is one of the biggest features I need to seriously consider AnyType as my main driver! :pray:

I strongly believe that the addition of a feature that enables the use of formulas and facilitates the migration of points from sums to financial notes would be a valuable asset to the Anytype :blush:

@sarah.arminta @Bsantana Can you please share how do you use this feature in your life?

I feel like I use formulas for just about everything.

  • To calculate how many active projects are related to the current goal, same for tasks related to projects.
  • To filter out and display only active dreams, goals, projects or tasks under life areas, dreams, goals and projects.
  • To display progress bars for my goals and projects.
  • To calculate the next do date for recurring tasks
  • To calculate the sentiment of my daily notes.
  • To display the day of the week for a specific date.
  • To automatically make relations between a date → week → month → quarter → year so I don’t have to constantly do it manually.
  • To automatically connect a workout to a daily note by matching and filtering the date.
  • To add, calculate averages, etc on stats like deep sleep, total sleep, hrv, readiness score, etc.
  • To roll up and concatenate properties like gratitude, wins, improvements for review purposes.
  • To automatically calculate the end date for say, a month, based on the provided start date.
  • To create entity names based on properties.
  • To calculate calories, macros, nutrients for recipes and meals.
  • To calculate weights for workouts based on reps, PRs, readiness score, etc.
  • To do all sorts of calculations for trading, investments, personal finances, etc, etc. Too many to list here.
  • To automatically extract tasks and properties from rich text.

I mean, I could go on and on. And if you add inline formulas to this, the list is even longer.

I can automatically populate and display relevant dates that auto update:

I can prominently display items that need my prompt attention so they don’t get forgotten:

I can create workouts that populate and calculate everything I need:

Just to add my thoughts to this, you’d be surprised at how much you can do when you can link multiple Objects and do some basic math from the Relations.

Outside of the specifics, from a high level, allowing an Object to take Relation data from another Object, maybe converting some text to numbers, then doing some math on that data is what we’re looking for I think.

@ignatovv
The formulas in my case will be used for personal financial calculations, stock/investment tracking. My idea is to be able to have all my notes and controls in one place. It is also interesting to be able to perform the calculations mentioned by @arminta7.

My wife uses Notion to manager her small business (customers, jobs, product cost, etc). She hates how slow Notion is, and would love to transition to Anytype. She only has about 100 records in her customer type but it is completely unusable due to the lag.

Hi everyone.

Its great to see so much support for formulas. I also believe that formulas are incredibly important to achieving the long term vision of Anytype, and I will continue to advocate for their prioritization.

The discussion of Formulas is very complex. The development of formulas automatically implies transclusion (transclusion is a pointer, we need pointers in formulas). Enabling formulas requires the development of a Domain Specific Language (DSL). I have spent the 2 years prior to using Anytype researching and designing prototypes for such a system. It is a very hard thing to get right (or even good enough), and it might very well require a reworking of the fundamental constructs we have. It also opens up the discussion of interoperability at multiple levels, and how they fit together. Not to mention security!

So it is important to understand the impact of the design decisions and scope of utility when designing a programming language, otherwise you get a new JavaScript. Do we make a limited LISP dialect with a client-side execution environment? Should it be executed in the middleware, a web worker? Do we use a subset of javascript, go, typescript, or perhaps something more fundamental like WASM? How will this system impact other possible extensibility vectors (SDK, Executable Code Blocks, Custom UI, etc)? How does the type system of the language, if any, work in conjunction with the concept of types when it comes to Objects? Should you be able to import packages? What about formulas on files (processing images, perhaps)?

We are dealing with the same hard questions that were answered by the developers of countless systems prior. It is important to learn the history, otherwise we will make the same mistakes. We need to understand the trade-offs before we add even more complexity to the system.

I am of the opinion that we will need a solid period of consolidation. Not just for this feature, but also to make the system extensible by outside developers and accelerate the pace of development. We need clean, non-leaky abstractions that will stand in 5 years time, hopefully even longer. We need to strive for abstractions as clear and powerful as UNIX’s everything is a file philosophy. But also to anticipate that analogies do break down (is everything REALLY a file? Maybe paper/folder analogies are bad. Maybe everything is an Abstract Syntax Tree. or a Graph). This is hard to achieve, but it is IMO ultimately our long term goal.

Anyway, I’m getting ahead of myself. its a very interesting topic! If you want some inspiration, check out:

Thanks for the detailed explanation!

However as users it’s also useful to know in more practical terms where this is realistically in your roadmap.
Can we expect this in 1 year, 5 years…?

It’s not in the roadmap. It’s my personal mission as a dev to get it on the roadmap as soon as possible after public beta launch. I believe we can get an initial version out within a year after public beta launch. This does not represent the opinion of the team as a whole. If you would like to see it happen, please continue engaging and making a case for the utility so that my fellow colleagues can see the potential and community support :slight_smile:

Thanks for clarifying @Dragos

it can be used extensively, sum or average of column values and all is just so important, like for gym logs and stuffs, i also it for calculating the amount of hours allocated to each subject in my work, which i have on notion as anytype doesnt support doing math. Database feature is like soo important. I will usrely share some usecases on the forum!

:smile:
I recently spoke with the Notion team about the same topic!
Have a block displaying an element of a base or a calculation based on a base, configurable via a formula, to be able to create dashboards!

Here are some use cases to support the suggestion…

Let’s take a database of support tickets ;-).
On the dashboard, it would be useful to display for example, from this value of the calculation line :

  • the number of open tickets not assigned (thus number of lines following these filters)
  • the average time of resolution (assuming a number field containing the duration of resolution, it would be the average of these fields)
  • and (probably with several blocks necessary) it will be possible to have the number of tickets for each category (Bug, Evolution, etc)

And…

  • Display the title/link of the priority ticket (filter by criticality, open and unassigned status and then display the title only)
  • Display the status of an important ticket in process (filter to have only this ticket then display the status)

A dashboard based on a “wine cellar” database :slight_smile:

  • total number of bottle
  • number of bottle by color
  • list of bottle ready to drink this year (ok, a filtered set is enough for that but I would just like the list without all the other display elements of a set around)

A citation base?
→ quote of the day

And with the widgets sidebar coming in Anytype, there will be many other uses!

To add some more use cases:

Formulas/queries could be used to replace/restructure/upgrade sets and inline sets.

Using a formula/query to generate a list of objects that have the current object as a relation. This can be used as a rollup type feature as another relation, but also it could be used inline to replace/provide an alternative to inline sets.
E.g., in a human object, generating a list of book objects where the author relation is that human object.
The formula for this could look something like: =query(object.book).filter(relation.author(object.current))

Using a formula to count the number of objects generated in a query.
E.g., in a human object, counting the number of book objects where the author relation is that human object.
The formula for this could look something like: =query(object.book).filter(relation.author(object.current)).count()

Using a formula/query to generate a list of uncompleted tasks that are assigned to me that are due this week
The formula for this could like something like: =query(object.task).filter(relation.due_date(>2023-05-14,<2023-05-20),relation.asignee(object.human(‘Bob’)),relation.task_status(FALSE)).sort(relation.due_date, asc)

Forgive my poor coding lol, but hopefully you get the general idea.

In my mind, Anytype would leapfrog all other platforms mentioned in this thread if they could implement this functionality. It’s amazingly powerful. It puts Coda in a league of it’s own and the absence of it is the only limitation of Anytype that prevents me from making the switch currently.

I agree that this is really needed.
And I insist on the REALLY !

But, in my case, I never liked the way Notion did it. I found it very cumbersome to use and not very practical. I found the Coda way more… intuitive. But I will let the developer choose a way that can work for most of us :slight_smile:

I can’t wait for the Anytype team to implement this powerful functionality. The formulas are what I miss most in Anytype. I don’t care if it’s finally done the Notion way or the Coda way, but it’s important to have it somehow.

lack of formula functionality, mainly within databases (aka collections) is the main thing holding me back from fully investing into AnyType. It is objectively better in every other way, but the lack of robust formula system is stopping me.

I absolutely need this to implement a “Completed At” timestamp. This would allow me to filter out tasks that were completed a long time ago

I love this. I hope, it will be implemented soon!