cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Power Query - extracting project ID in text

Hi,

 

I have an excel field that contains a project ID, and a description. In perfect conditions it should be: P2019 00002 - Project of House Credit.


I want to extract the ID in Power Query Editor, wich should be easy (a simple extract before limiter "-"), and i would get the ID: P2019 00002.

 

The problem, is that this field is filled by more than 80 people, many of whom like to freestyle and not fulfill the filling instructions. I get things like:

 

  • Project of House Credit - P20109 00002 - further description (with limiters)
  • Project of House Credit P2019 00002 blablabla (with no limiters)
  • P2019 002 - House of credit (missing zeros)

Assuming there will always be people who do not follow the rules, how would you approach this? I would not want by now to create an unique column in excel for people to put the ID... (last approach only). 

 

Is there a way to extract the numbers from a text for instance? 

 

Many thanks, friends

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User V
Super User V

Re: Power Query - extracting project ID in text

Hi @campelliann ,

 

Use this code for a custom column:

Text.Combine(List.Select(Text.Split([Column1], " "),
each
if Text.Length(Text.Select(_, {"0".."9"})) > 0 then true
else false)," ")

 

Capture.PNG 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
Highlighted
Super User VII
Super User VII

Re: Power Query - extracting project ID in text

@campelliann to extract before 2nd space will do? I see that as the common pattern?

 

 






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Highlighted
Super User V
Super User V

Re: Power Query - extracting project ID in text

Hi @campelliann ,

 

Use this code for a custom column:

Text.Combine(List.Select(Text.Split([Column1], " "),
each
if Text.Length(Text.Select(_, {"0".."9"})) > 0 then true
else false)," ")

 

Capture.PNG 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors