Help between Notion users

It's free & easy

Receive points, vote and give the solution

1vote

# And if you wanted to get the last word from a rollup, containing multiple commas??

Trying to get the last two words from a rollup containing multiple commas in variable amounts. Need a formula that slice the string before the second last comma, and return everything after that. Currently googling regex trying to find the answer. If someone knows, please answer.

1vote

aloreols Points160

I had a similar problem. You can make the necessary tweaks to my code, if you find it useful.

As a bit of context, I had to slice a string made up of numbers separated by a hyphen, something like this: 2022-10-21. Basically, it's a date, although Notion won't recognize it as such. So, I created 3 formulas, each one to get the three parts of the string separately. I named these shorter strings "1st slice", "2nd slice", and so on.

The name of the string is prop("Name")
The first formula is: `replaceAll(prop("Name"), "-.*", "")`
The second formula is: `replaceAll(if(length(prop("Name")) > length(prop("1st slice")), replaceAll(prop("Name"), concat(prop("1st slice") + "-"), ""), ""), "-.*", "")`
The third formula is: `if(length(prop("Name")) > length(prop("1st slice")), replaceAll(prop("Name"), concat(prop("1st slice") + "-" + prop("2nd slice") + "-"), ""), "")`

After that, you just have to concatenate the strings you obtain. If you need any further help, I will be glad to help you.

1vote

### viralsleep commented Nov 21

Thanks for the solution. Ended up splitting the data into more than one row, and pulling the data using end().

0vote

### polle commented Nov 21

@viralsleep please add a new answer below with a formula example and select it. For sure it will help others with the same problem.

0vote

### viralsleep commented Nov 21

Will do so. However, the solution was simplifying the database itself, so that the complicated formula was no longer needed. Will post an explanation of that, with end result.

0vote

viralsleep Points170

Update on the solution to my question above.

As mentioned in a previous reply, realized was trying to solve a constructed problem. Had built a workspace for our team in Notion. In it am using a PARA structure (Projects, Areas, Resources, Archive). Using hierarchical databases to manage tasks from (Areas > Goals > Projects > Tasks > Todos > Time).

In the time database had sorted the data into two categories: Quarter and Month. The core database is Projects as that is where most things are defined, especially the time estimates. Was allowing project owner to select multiple time pages (i.e. multiple quarters or months).

This gave me multiple date ranges in the related column. So in order to calculate the deadline, estimated completion, was using trying to use end() to pick the last date. Obviously, this did not work as the data was a string() not a date().

That's when the question here was posed as was trying to extract the last date of the string which contained multiple date ranges.

Realized this was an overcomplicated solution, and ended up creating time templates consisting of Months, Quarters, and Halfs. Also restricting each project to only one of these. So by default, if the project is longer than 6 months, we split it up into multiple projects.

Not the technical solution expected to end up with, but was much faster to implement and actually works really well in practice.

Hope it helps someone else if they read this.

...