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