View only the last 4 lines in a data field?

  • 0
  • 1
  • Question
  • Updated 4 months ago
  • Answered
Hi, I'm new to QuickBase and I'm having trouble with a formula for a text field. We have data line 1-7, but I only want to pull the last 4 lines in the data (data lines 4-7). I've tried using the part & right formula, but I can't seem to make it work. Any ideas?

Here's the formula we've been using, but I need the last 4.
Right(Right([Long Text],"\n"),"\n")

Thanks!
Photo of Catelyn Atkinson

Catelyn Atkinson

  • 152 Points 100 badge 2x thumb

Posted 4 months ago

  • 0
  • 1
Can you post an example of what your data looks like?
Even if they have other time zones, you could add variables to successively replace them all with the delimiter.
Photo of Catelyn Atkinson

Catelyn Atkinson

  • 152 Points 100 badge 2x thumb
Hi, Thank you for the code. We tried using this code and we get a formula error. 
A formula may not contain a reference to itself directly or indirectly through another formula. 

Here's the updated code I used. 
var text StepOne = SearchAndReplace([Long Text Formula],"MST","|");

var text Message = Right($StepOne,"|");

var text RestOfMessage = NotRight($StepOne,"|");

var text DateStamp = Right($RestOfMessage,"\n");

Trim($DateStamp & " MST " & $Message)

Thanks!
I suspect that you need to change this

var text StepOne = SearchAndReplace([Long Text Formula],"MST","|");

 to this

var text StepOne = SearchAndReplace([Long Text],"MST","|");
Photo of Catelyn Atkinson

Catelyn Atkinson

  • 152 Points 100 badge 2x thumb
Hi, It worked. Thank you so much! 

I appreciate your time. 
Hi Catelyn. You're running into a common problem resulting from what's called a de-normalized database. It's a technical concept, but basically in your case you have several records worth of information stored in a single field, and so it's hard to retrieve just a portion of that field to display somewhere else.

Another example of the same kind of thing (but much simpler and therefore easier to resolve) is if you have a person's full name stored in a single field, like "Sam Q. Jones IV" and want to extract only the last name or the middle initial.

I don't know of a way using a native Quick Base formula to return only the most recent message, especially if there are an unlimited number of messages appended to the field, and they vary in length and formatting.

The best solution is probably to normalize the database by adding a child table that will hold a single record for each one of these messages. From there, it's easy to surface only the most recent message on a form or in a report either by using a Report Link field or a reverse relationship.

I'm happy to help further if you need it.

Yours truly,

Phillip


PHILLIP DENNIS
Principal | Watkyn LLC
Quick Base Solution Provider
(954) 900-6690 | hello@watkyn.com
www.watkyn.com
Watkyn LLC
Caitlyn, can you clarify the ask here. In the example above what is the result you are looking for?