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
Bill Beauchene 24Bill Beauchene 24 

Salesforce Formula to determine the number of spaces in a text field.

I am trying to create a formula in Salesforce to count the number of spaces in a text string and determine if the count of total spaces is less than one.

Not sure if that is even possible, please let me know if you need more context. 

Best Answer chosen by Bill Beauchene 24
Sunil RathoreSunil Rathore
Hi,

To calculate the number of spaces in the text field, use this formula:
Len(Field Name)- Len(SUBSTITUTE(Field Name, ' ', ''))

The above formula will give you the total number of spaces in a text string and to determine the count of total spaces is less than one use :
Len(Field Name)- Len(SUBSTITUTE(Field Name, ' ', '')) < 1

Let me know if above formula solves your problem.

Many Thanks,
Sunil Rathore

All Answers

Sunil RathoreSunil Rathore
Hi,

To calculate the number of spaces in the text field, use this formula:
Len(Field Name)- Len(SUBSTITUTE(Field Name, ' ', ''))

The above formula will give you the total number of spaces in a text string and to determine the count of total spaces is less than one use :
Len(Field Name)- Len(SUBSTITUTE(Field Name, ' ', '')) < 1

Let me know if above formula solves your problem.

Many Thanks,
Sunil Rathore
This was selected as the best answer
Bill Beauchene 24Bill Beauchene 24

This works, thanks Sunil!