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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
leopoldvili_1
Helper I
Helper I

How to extract letters and digits in string in Power Query

Hi, 

I would like to extract text from the input string and get the result provided in the output by using Power Query.

input:

hello bd AD-001234 hb

this is AD-3245

 

output:

AD-001234

AD-3245

Can anyone give me some tips? not using R?

Thank you

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @leopoldvili_1 

 

Download example PBIX file

 

Create a Custom Column with this code

 

List.Select(Text.Split([input]," "), each Text.Contains( _ , "-")){0}

 

 

outp.png

 

outp2.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!


View solution in original post

4 REPLIES 4
leopoldvili_1
Helper I
Helper I

Thank you! @PhilipTreacy  it works!

Ashish_Mathur
Super User
Super User

Hi,

What is basis of extraction?  Everthing from AD till the next space?  Please clarify.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
PhilipTreacy
Super User
Super User

Hi @leopoldvili_1 

 

Download example PBIX file

 

Create a Custom Column with this code

 

List.Select(Text.Split([input]," "), each Text.Contains( _ , "-")){0}

 

 

outp.png

 

outp2.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!


Any way to add an if statement where if another column has a certain value then apply the extraction

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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