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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
julienvdc
Helper III
Helper III

Using Power Query to extract the first occurring number from a string (URL)

I have a coumn with URLs from which I would like to extract the first occuring number. My constraints:

  • the numbers don't occurre at the same position
  • there might be some numbers further in the string that I do not want to extract
  • the number to extract does not always have the same length
  • i just want to extract the first occurring number (starting from the left).

It seems quite simple but I haven't found any previous posts sharing a solution to a similar issue...

 

Any ideas how I could achieve this?

 

I am thinking that if I can find the starting and ending position of that number then I could perhaps use splitter.SplitTextByPosition...

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

 

Text.Combine(List.FirstN(
List.Select(
    Text.Split(Text.Select(
        [Column1],{"0".."9","/"}),"/"),(x)=>x<>""),1))

 

Screen Capture #464.png

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

 

Text.Combine(List.FirstN(
List.Select(
    Text.Split(Text.Select(
        [Column1],{"0".."9","/"}),"/"),(x)=>x<>""),1))

 

Screen Capture #464.png

It workssssssssss! thank you so much for the quick support! Hope this helps others in the future.

julienvdc
Helper III
Helper III

Here is an example.

 

My column would have URLs as such:

/questions/11928/qwertyuio-asdfghj-34.html

/questions/7229/can-you-share-your-experience-in-developing-a-trai.html?childToView=8665#answer-8665

/articles/11867/jhbvcfgtyujn-4.html

/idea/11875/kjhgukjnk.html

/content/idea/234/kjhgukjnk.html

/content/articles/888383/jhbvcfgtyujn-4.html

 

The extract would be as such:

11928

7229

11867

11875

234

888383

Ahmedx
Super User
Super User

post an example and the desired result

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.