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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Anonymous
Not applicable

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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