⚪ More details in Help topic for writing calculations

This would be really helpful for someone who is not a coder. I can do the basics, like reference a relationship, but I don’t know how to, for example, count the number of records connected via a relationship, or sum the total of a number field that each of those contains. I realise this is potentially an endless job, but at the moment, the only help I get is error messages if I get it wrong!
thanks!
Matthew

Hi @matthewcock,

I totally agree and this is something where we have indeed not lived up to our own expectations so far. :confused:

While we added various guides in the last weeks and also try to come up with code snippets whenever questions are asked, it would be great to extend our calculation field developer guide with more examples and code snippets. Be sure that we will work on improving what we have there, right now it’s not sufficient.

In the meantime, do not hesitate to ask your questions here. It is great to see people’s ideas and solutions to real world problems manifesting in calculation code snippets that can be copied and used as a baseline.

Regarding your two concrete examples:

Count the number of records connected via a relationship

This can be achieved by accessing one of the relationship’s field tokens and using the length property. If you only care about how many records are related, you can use the “with null” variant of the respective token. In my example here, I am using the “All of Title with nulls” token:

Sum the total of a number field that each of those [related records]

This can actually be solved without code, as Tape offers a few aggregations out of the box. If you start typing “@” and your number field name (in your related app), you will see a couple of suggestions:

Common use cases like sum, average, max and min are already available there and should work out of the box for you.

Let me know how it goes, and hopefully these infos can already unblock you solving your use cases for now. Reach out anytime if you have follow up questions here.

Cheers
Tim

4 Likes

Thanks Tim! (and sorry for late response, I’ve been busy!)

1 Like