Skip to main content
Solved

Remove part of a string

  • September 9, 2024
  • 6 replies
  • 0 views

I have a name and the corresponding date of birth in a data field, separated by a "|" I would like to use a formula so that only the name is displayed to me. the name is before the "|" sign. I tried LEFT, but only got ERROR

Best answer by TheTimeSavingCo

Try:

LEFT(
Name,
FIND(
" | ",
Name
) - 1
)

View original
Did this topic help you find an answer to your question?

6 replies

TheTimeSavingCo
Forum|alt.badge.img+18

Try:

LEFT(
Name,
FIND(
" | ",
Name
) - 1
)


kuovonne
Forum|alt.badge.img+17
  • Brainy
  • 5987 replies
  • September 9, 2024

Do you have any records where the field has a name, but does not have the "|" character? If so, Adam's formula will not extract the name. There are many ways of doing things in formulas, here is one alternative that will get the name before the "|" or return the full value if there is no "|".

 

TRIM(
REGEX_EXTRACT({Name}, "[^|]*")
)

 


You might also want to look at why the field is setup as it is. In good database design, each editable field should contain the smallest unit of meaningful data. In this field, you have two different pieces of meaningful data (name and birthdate). 

How is the field with the name and birthdate getting its values? If it is a formula field, is it based on separate fields for the name and birthdate that you can use? If it is a text field with data that is entered manually, can you redesign the base so that the data is entered into two different fields? If it is a text field that is populated via an integration or automation, can you edit the integration or automation?


  • Author
  • Inspiring
  • 30 replies
  • September 10, 2024
kuovonne wrote:

Do you have any records where the field has a name, but does not have the "|" character? If so, Adam's formula will not extract the name. There are many ways of doing things in formulas, here is one alternative that will get the name before the "|" or return the full value if there is no "|".

 

TRIM(
REGEX_EXTRACT({Name}, "[^|]*")
)

 


You might also want to look at why the field is setup as it is. In good database design, each editable field should contain the smallest unit of meaningful data. In this field, you have two different pieces of meaningful data (name and birthdate). 

How is the field with the name and birthdate getting its values? If it is a formula field, is it based on separate fields for the name and birthdate that you can use? If it is a text field with data that is entered manually, can you redesign the base so that the data is entered into two different fields? If it is a text field that is populated via an integration or automation, can you edit the integration or automation?


Unfortunately I only get an ERROR with the formula.


  • Author
  • Inspiring
  • 30 replies
  • September 10, 2024
TheTimeSavingCo wrote:

Try:

LEFT(
Name,
FIND(
" | ",
Name
) - 1
)


I have already tested this formula but the formula only gives me an ERROR.


  • Author
  • Inspiring
  • 30 replies
  • September 10, 2024
user2100 wrote:

Unfortunately I only get an ERROR with the formula.


I managed it. It was probably because it was a linked field. I tried it with an unlinked field and it worked. thanks for the numerous help.


TheTimeSavingCo
Forum|alt.badge.img+18
user2100 wrote:

I managed it. It was probably because it was a linked field. I tried it with an unlinked field and it worked. thanks for the numerous help.


Glad you figured it out!  For a lookup field you can try the following too:

 

LEFT(
Name & "",
FIND(
" | ",
Name & ""
) - 1
)

 

 


Reply