Unfortunately, there is no function available in SharePoint calculated column formulas which will replace all spaces from column value automatically.
SharePoint calculated column formulas supports REPLACE
function which replaces only one instance of the space character at a time.
So, if you want to replace multiple space characters, you will have to replicate the same REPLACE function logic for all spaces.
You can find some similar questions for more information at:
- Calculated Column Formula how to replace Substitute
- Sharepoint function to replace multiple characters
- replace text with formula in calculate
Additional:
If you just want the replaced mobile number for display purpose in SharePoint list view only, you can use JSON formatting for your requirements.
- Create a calculate column using simple formula like:
="Mobile Number"
- Then apply JSON column formatting to your calculated column and use below JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=replaceAll([$ContactNumber], ' ', '-')",
"style": {
"font-weight": "bold"
}
}
Where ContactNumber
is the internal name of column with spaces in it. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?
Follow the steps given here to apply JSON column formatting: Use column formatting to customize SharePoint
Output:
Reference: SharePoint: Replace All Occurrences of Substring in a String using JSON Formatting