Forum Discussion
Extracting specific number form alphanumeric text
- 7 years ago
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
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.
There's no easy DAX way that I can think of off the top of my head, perhaps ImkeF has an M way.
- ImkeF7 years ago
Community Champion
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- Anonymous7 years agoNot applicable
Thanks for the inputs. I am not trained with M query. Can this be used while adding custom column?
Will request you to share any quick tutorial that might help me to implement the solution.
- ImkeF7 years ago
Community Champion
You can find that tutorial here: https://www.thebiccountant.com/2019/01/30/add-a-column-with-custom-function-code-in-power-query/
- Anonymous6 years agoNot applicable
Following up with another solution i learned for this problem from my peer.
Replacing 9 with |9 (delimiter), extracting text after delimiter and replacing delimiter (|) with nothing.
Regards,
Vippan
- Anonymous7 years agoNot applicable
Hello Greg,
Thanks a lot for your help.
regards