Forum Discussion
Anonymous
7 years agoNot applicable
Extracting specific number form alphanumeric text
Hi. Need help in extracting consecutive numeric string from cell. for example extracting "987654321" from string below
"P06 Payroll 92 team 32A ACCRUAL 987654321 Sub"
Numeric string to be pulled can begin from any number however total digits in string will always be same.
Not particularly elegant, but works for me:
(TextInput as text) => let Source = TextInput, Custom1 = Text.Split(Source, " "), Custom2 = List.Select(Custom1, each Text.Length(_) = 9), Custom3 = List.Transform(Custom2, each Text.ToList(_)), Custom5 = List.Select(Custom3, each List.MatchesAll(_, (li)=> List.Contains({"0".."9"}, li))){0}, Custom4 = Text.Combine(Custom5) in Custom4
8 Replies
- Greg_DecklerCommunity Champion
Does it always follow a specific term or number of spaces from the beginning or the end?
- AnonymousNot applicable
there is no specific place in string this might come. Dpending on user input (geogrpahically dispersed users), numeric string can appear anywhere in the cell. Numeric string to be pulled out will always be 9 characters if that helps.
- Greg_DecklerCommunity Champion
There's no easy DAX way that I can think of off the top of my head, perhaps ImkeF has an M way.