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.
Connect
Notion Answers
Help between Notion users
Register & Ask
It's free & easy
Get answers
Answers, votes & comments
Vote and select answers
Receive points, vote and give the solution
Question
2 Answers
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.
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.
Related questions
- How can I get the max between several dates stored in one porperty from a rollup?
- is there a way to pull the latest date from multiple related items?
- How do you select to display only positive numbers from a rollup
- How to find first and last dates of a week from a date property
- How do i rollup by months
Without Answer
-
- 75
- 0
- 2 days ago
-
- 97
- 0
- Sep 4
-
- 81
- 1
- Aug 29
-
- 66
- 1
- Aug 26
-
- 371
- 1
- Jul 4
-
- 595
- 1
- May 14
-
- 449
- 1
- May 9
-
- 485
- 1
- May 4
- see all
Exclusive for Notion Answers Users
- • Dynamic Calendar Icon | Info | Download
- Add yours here
Recent Activities
notionhq selected an answer 3 hours ago
Fatal error during installationgoatqueen asked 2 days ago
Filter & calculate attendance every yearnotionhq selected an answer 2 days ago
How I can auto fill a data base with consecutive n…polle commented 3 days ago
Need help with a time formulaLach answered 3 days ago
Need help with a time formula