function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eric FortenberryEric Fortenberry 

How can I create a field that equals another field but truncates everything after '-'?

I would like to add a field to our Accounts that equals the account name up until there is a dash '-'.  We do not want anything after the dash to be in this new field.  How can I do that?  I've created a new custom field, but am not sure how to write the formula to accomplish this.  Thanks for the help!

Best Answer chosen by Admin (Salesforce Developers) 
Paul.FoxPaul.Fox

You might want this instead:

if(contains(Name,"-"),LEFT(Name, FIND("-", Name) - 1),Name)

 

All Answers

Eric FortenberryEric Fortenberry

Figured this part out.

 

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

 

Paul.FoxPaul.Fox

You might want this instead:

if(contains(Name,"-"),LEFT(Name, FIND("-", Name) - 1),Name)

 
This was selected as the best answer