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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. 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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.