+ Start a Discussion
srichardsonsrichardson 

Formula to count the characters in a text field?

Is it possible to create a custom formula to count the number of characters in a Text field? 

Best Answer chosen by Admin (Salesforce Developers) 
srichardsonsrichardson

Answered my own question... LEN() - returns the number of characters in a text string.

All Answers

srichardsonsrichardson

Answered my own question... LEN() - returns the number of characters in a text string.

This was selected as the best answer
Starz26Starz26

LEN will cout spaces as well.

 

If you want just CHR counts, you will need to TRIM the stirng and then use LEN to return the number of CHR. If you do not want to count special ASCII CHR like ();: etc you will need to adjust some code for that as well.

Paulo Sergio SoaresPaulo Sergio Soares
How do I TRIM() and LEN() "at the same time"? Tried TRIM(LEN( Description )) but it doesn't work..
0l0r1n0l0r1n
Len(Trim(Description)) should work
Paulo Sergio SoaresPaulo Sergio Soares
It worked, thanks!
Ingrid Stone 1Ingrid Stone 1
Great but how do you do this with large Text fields?
Ingrid Stone 1Ingrid Stone 1
actually one smll problem when this runs and the field is blank it gives an error - how do I add a chack for this to only count if the field has a value in ir?
Jean-Sébastien PlanteJean-Sébastien Plante
IF(ISBLANK(field), 0, LEN(TRIM(field)))
Tony AndersonTony Anderson
What if you wanted to count the blanks as well?
Sachin JeremiahSachin Jeremiah
what is the correct procedure to calculate the length of a  number field ??