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
rajpal_singh
New Member

Extract numbers from a string column in excel using power query

Hi Community,

 

Can someone please help?

 

How can I extract the numbers from the string in Excel or CSV files using Power Query.

Like in the example below:

 

Screenshot 2024-09-10 at 8.17.05 PM.png

Thanks for your help in advance.

2 ACCEPTED SOLUTIONS
AlienSx
Super User
Super User

Splitter.SplitTextByWhitespace()(Text.Trim(Text.Select(your_text, {" ", "0".."9"})))

View solution in original post

Omid_Motamedise
Super User
Super User

use this formula (I have split it into several steps to be more clear)

let
    Source = Table.FromColumns({{"This is a 500 of 600", "800 of 558 available", "order has 60 of 20"}},{"Description"}),
    #"Added Custom" = Table.AddColumn(Source, "S1", each Text.Split([Description]," ")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "S2", each List.Transform([S1], each try Number.From(_) otherwise null)),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "S3", each List.RemoveNulls([S2])),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Custom", each Record.FromList([S3],{"column 1"," column 2"})),
    #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom3", "Custom", {"column 1", " column 2"}, {"column 1", " column 2"})
in
    #"Expanded Custom"

 

 


If my answer helped solve your issue, please consider marking it as the accepted solution.

View solution in original post

3 REPLIES 3
Omid_Motamedise
Super User
Super User

use this formula (I have split it into several steps to be more clear)

let
    Source = Table.FromColumns({{"This is a 500 of 600", "800 of 558 available", "order has 60 of 20"}},{"Description"}),
    #"Added Custom" = Table.AddColumn(Source, "S1", each Text.Split([Description]," ")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "S2", each List.Transform([S1], each try Number.From(_) otherwise null)),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "S3", each List.RemoveNulls([S2])),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Custom", each Record.FromList([S3],{"column 1"," column 2"})),
    #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom3", "Custom", {"column 1", " column 2"}, {"column 1", " column 2"})
in
    #"Expanded Custom"

 

 


If my answer helped solve your issue, please consider marking it as the accepted solution.
AlienSx
Super User
Super User

Splitter.SplitTextByWhitespace()(Text.Trim(Text.Select(your_text, {" ", "0".."9"})))
Greg_Deckler
Community Champion
Community Champion

@rajpal_singh Can you post that sample data as text? Seems like you could split the column based on " of " perhaps and go from there. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.