Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Extract some text from within a block of text into a new column

I need to extract some text from within a block of text into some new columns

 

Here is an exampe of the text. From it I need to create a column containing the leaver name (Daniel) and the date of leaving (11/09/2020). Would I do this using the Search function?

 

The Leaver Notification for Daniel has been confirmed by HR.

HR014 Details:
Leaver Name:Daniel
Date of Leaving: 11/09/2020

Emails to be forwarded: Yes
Email to forward to: steve
Is access to the user's files to be given? No
If yes, acess to be given to:
Remove person from the system from: 12/09/2020
Cancel phone account: No
If yes, mobile phone number:

For any questions, please email the 'UK HR' mailbox

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Check the formula.

name = 
var start1 = SEARCH("Leaver Name:",'Table'[Column1])+12
var end1 = SEARCH("Date of Leaving:",'Table'[Column1])-1
var start2 = SEARCH("Date of Leaving:",'Table'[Column1])+16
var end2 = SEARCH("Emails to be forwarded:",'Table'[Column1])-1
return
MID('Table'[Column1],start1,end1-start1)&MID('Table'[Column1],start2,end2-start2)

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Check the formula.

name = 
var start1 = SEARCH("Leaver Name:",'Table'[Column1])+12
var end1 = SEARCH("Date of Leaving:",'Table'[Column1])-1
var start2 = SEARCH("Date of Leaving:",'Table'[Column1])+16
var end2 = SEARCH("Emails to be forwarded:",'Table'[Column1])-1
return
MID('Table'[Column1],start1,end1-start1)&MID('Table'[Column1],start2,end2-start2)

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Download this sample file with the following code

Try this in Power Query

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY/NTsMwEIRfZdQzUpMICeELBwJqBeohiAMqPTjtpI0Ue4PtBPL2OD9F3Nb+dmZn9vvVpkjSW+QMum68eqXu6bDThirXtmaDXAdCKoyotmeFNF0n9+ssyRI8mVGFICiJSty3dieeFD7oZzai5T+OCm+BPbH10Mcj/aQMF6LzdJ9dkmR3HlXd8Gp5rnvaB+wE2woD/U3ULbIrnWwLGom+LZ0Xi8qJmWz94APN9I6xs7/Yj9oeY7P2IpZjEulsUP+vGCljimXBdqakU3gWB20HfHX0oRYb99qG2hOcq8aLc4n3F2yKecSISvlZHQ6/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Text.BetweenDelimiters([Column1],"Leaver Name:","Emails to be forwarded")),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom", "Custom", Splitter.SplitTextByDelimiter("Date of Leaving:", QuoteStyle.None), {"Custom.1", "Custom.2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Split Column by Delimiter",{{"Custom.1", "Leaver Name"}, {"Custom.2", "Date of Leaving"}})
in
    #"Renamed Columns"

 

 

leav.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.