Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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.
Solved! Go to Solution.
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
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Does it always follow a specific term or number of spaces from the beginning or the end?
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.
Hello Greg,
Thanks a lot for your help.
regards
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
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
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
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.
You can find that tutorial here: https://www.thebiccountant.com/2019/01/30/add-a-column-with-custom-function-code-in-power-query/
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
User | Count |
---|---|
125 | |
106 | |
99 | |
63 | |
62 |
User | Count |
---|---|
135 | |
116 | |
101 | |
71 | |
61 |