🤝 Brainstorm Hours: share your ideas on which new functions to add to the Baserow formulas?

Let’s give another chance to the initiative — Brainstorm hours, where we want to have direct collaboration between our community and the team, and ask you to participate in the brainstorming session and share your thoughts on certain features.

Today’s topic: Formula Functions.
We know Modulus () is the most awaited one, and it will be added shortly. Which else functions to add to the Baserow formulas?

Round ()
Ceiling ()
Floor ()

Add your voice! The team members are listening :writing_hand:

2 Likes

Thanks for consulting the community!

How about choosing one well designed and documented library (in python? or another language that fits the need) and have loaded and usable in formula cells?

field('field_name') and lookup('table_name', 'field_name') would then be the two extra things to add to the chosen library.

I indeed think about pandas as it is thought for working with tables, though it might be an overkill as right now formula cells only have access to the cells of the same row.

Giving access to the content of all cells to formulas would be a great thing.

1 Like

@nigel perhaps you could comment on this request :slight_smile:

Thanks in advance!

@jibe-b Formulas under the hood are implementing using SQL. So unfortunately we can’t easily just plug in another python library and make it available in the formula language. Additionally the goal of the formula language is to make it a simple expression language that non-technical users can use. Somehow offering python code in formulas would go against this design goal.

Now perhaps in the future a Python field plugin might come along, which could do exactly what you describe. But we have no concrete plans for such a plugin/offering yet.

Separately there are potential future formula functions we could add that would allow accessing other cells. For example something like vlookup or some sort of table_join functions. But once again these aren’t on the current roadmap, but perhaps they will be soon :)?

How cool to be able to participate in this construction! :star_struck:

I would like to see more string handling functions, like these:

split()
replace()
slice()
toLowerCase()
toUpperCase()
trim()

2 Likes

An easier way to convert a boolean to a number would be nice. On several occasions, I’ve found myself wanting to to some sort of math operation (e.g. sum) on a variety of things that return true/false, and I first need to awkwardly use an if-statement to convert that to 1/0.

@claudiobalbino

The following functions already exist and can be used today in Baserow out of your list:

  • trim
  • replace + regex_replace
  • lower is toLowerCase()
  • upper is toUpperCase()

slice and split do not exist yet. Can you provide some examples on how exactly they would work?

I believe you can use the existing left and right functions to slice up a string, but I agree a single “slice” function would be nice which possibly worked like this?

  • slice('abcde', 1,2) = 'bc'
  • slice('abcde', 0,5) = 'abcde'

Now for split I’m not sure how this would work currently if I’m assuming you mean “split this piece of text into a list of smaller pieces of text” as the formulas don’t exactly have a “list” type that you can work with not via link fields atm. But its certainly possible to add a first class “list” type to the formula language that could work like so:

  • split('one, two, three', ',') = ['one', 'two', 'three']

Is something like the above what you had in mind?

2 Likes

Hm this is a great idea. We could extend the existing tonumber function that converts text → number to also allow converting a true → 1 and false → 0.

Ontop of that we could implicitly convert under the hood:
sum(field('boolean lookup'))
into
sum(tonumber(field('boolean lookup'))

And so with this implicit adding of “tonumber” sum would just work with booleans out of the box. Do you think this also would make sense? Or is it a bit too magic perhaps?

You could go even further and make the formula language allow things like:

1 + true = 2

But i think this potentially goes too far than just making sum work with booleans, and might result into users writing buggy formulas and not realizing it. Where-as having tonumber is more opt-in and hence less unexpected: 1 + tonumber(true) = 2.

1 Like

Hi Nigel,

Good to know that some of the suggestions can already be made in Baserow…I’ll try them out :star_struck:

About slice the idea is that it works as in your example. As for the split, I would like, for example, to get only the first name of the full name

Captura de tela 2022-09-30 074006

Other examples can be seen in the link below.

2 Likes