Forum Discussion
Learner22
3 years agoHelper I
Extract number from a string column
Dear community, I have a column with text and numbers in a table. I would like to have the numbers in a separate column. What is the best was to do this? Here are two examples 1. xxxxxx...
- 3 years ago
Hi Learner22
Purely based on your example, I would first filter the column to the rows that contain the word "ordernumber".
On that filtered table, you can split the column based on the colon (":"),
and finally trim the number to get rid of leading and trailing spaces.
If I create an Excel table called Table1, like this:
Input
xxxxxxxxx 34 xxxxxxxxx ordernumber: 8100006833 xxxxxxxxx 45 xxxxxxxxx Then, from the Excel table, if I create a Power Query by going to Data - From Table/Range, here is a recipe to extract the order number:
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Input", type text}}), #"Filtered Rows" = Table.SelectRows(#"Changed Type", each Text.Contains([Input], "ordernumber")), #"Split Column by Delimiter" = Table.SplitColumn(#"Filtered Rows", "Input", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Input.1", "Input.2"}), #"Trimmed Text" = Table.TransformColumns(#"Split Column by Delimiter",{{"Input.2", Text.Trim, type text}}), #"Changed Type1" = Table.TransformColumnTypes(#"Trimmed Text",{{"Input.2", Int64.Type}}) in #"Changed Type1"
Syndicate_Admin
3 years agoAdministrator
Please provide sample data in the format that your scenario produces. It is not clear from your example what format that is.