cancel
Showing results for 
Search instead for 
Did you mean: 
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

3 REPLIES 3
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!


Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors