Using calculated field to retrieve substring of another field
-
07-12-2019 - |
Question
Suppose I have a field that contain the following data:
========================== | Email Address | ========================== | Jack@wonderland.com | | Peter@nobodyland.com | | Jill@wonderland.com | ==========================
Is there a calculated formula in SharePoint that will give me the following result? (It will help me to retrieve the sub-string from the Email Address
column and give me the answer as shown in the UserName
and Domain
column):
=========================================================== | Email Address | UserName | Domain | =========================================================== | Jack@wonderland.com | Jack | wonderland.com | | Peter@nobodyland.com | Peter | nobodyland.com | | Jill@wonderland.com | Jill | wonderland.com | ===========================================================
Solution
Create Calculated column called "UserName" and type in this formula
=LEFT([Email Address],INT(FIND("@",[Email Address])-1))
Create Calculated column called "Domain" and type in this formula
=RIGHT([Email Address],LEN([Email Address])-INT(FIND("@",[Email Address])))
It should work.
OTHER TIPS
It appears that there's no such functions in the list of supported functions: http://msdn.microsoft.com/en-us/library/bb862071.aspx. I can offer a workaround - you can create custom field with modified XSLT to achieve desired effect. Here's the example: http://www.intheknow.it/Default.aspx?Page=customxsltfieldrendering&NS=&AspxAutoDetectCookieSupport=1