Substring function

EDIT : just saw there’s this issue for the particular problem of thousands separators, but I think the availability of substring may attract (or not) some votes if searched by others

Context
I have a column with numbers ranking from a thousand to billions, and I want to display them nicely (ie 10001.000, 18900001001.890.000.100).

Frustration
Currently, we have a left and right function to catch text from the beginning or the end of a text. But in order to obtain the result above we have to go through a lot of intermediary formulas in order to avoid a function mess.

However, when we want to extract a specific substring by indices, it is not possible.

Solution
Implement a substring function which could work this way

substring(string: str, start: int, end: int) -> str

# Pythonic way
substring('naturally', 1, 4) = 'atu' # Python equivalent of 'naturally'[1:4]

# more-clear way
substring('naturally', 1, 4) = 'natu' # Python equivalent of 'naturally'[0:4]
1 Like

@nigel do we have any plans to add the substring function to the Baserow formulas?

It would be trivial to add as postgres itself supports it: PostgreSQL SUBSTRING() function - w3resource

Basically at some point I want to reach the point where:

  1. Every single postgres function (that makes sense) is available in the Baserow formula language
  2. Every single column/data type in postgres is also available in the Baserow formula language

That said the above is a big job and we are incrementally chipping away at it. I’ll make an issue tracking Add every sensible string postgres function to Baserow formulas PostgreSQL: Documentation: 11: 9.4. String Functions and Operators

4 Likes