Forum Discussion
Extract alphanumeric words from a Power Query text string
- 1 year ago
Given your example, you merely have to split Description by space or comma, and then select any word that begins with "0".
let //change next line to reflect actual data source Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}, {"Date", type date}, {"Description", type text}}), #"Extract Descriptors" = Table.AddColumn(#"Changed Type","Value", (r)=> [a=Text.SplitAny(r[Description],", "), b=List.Select(a, each Text.StartsWith(_,"0"))][b], type {text}), #"Expanded Value" = Table.ExpandListColumn(#"Extract Descriptors", "Value") in #"Expanded Value"If your posted sample is not truly representative, you might need to add tests for length of the word, inclusion of the hyphen, inclusion of alphabet characters, etc.
- 1 year ago
The code is meant to be pasted into the Advanced Editor all by itself, NOT into the custom column dialog. And you must change the Source line to reflect your actual data source.
Hi telesforo1969 ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you wdx223_Daniel ronrsnfld jgeddes for the prompt response.
The error happens because Excel 2016 Power Query doesn’t support the function Splitter.SplitTextByCharacterTransition (it only exists in newer versions like Excel 365 or Power BI Desktop).
In Excel 2016 you can still achieve the same result by:
Splitting your text column into words using spaces and punctuation as delimiters.Filtering the list so that only words starting with 0 remain.Cleaning those words so they only contain letters and digits.Expanding the results so each matching word appears in its own row.This way you’ll get the same outcome (e.g. from "test 1234 0123 ABC 0456 XYZ" you would see 0123 and 0456 as separate rows), but without relying on unsupported functions.