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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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