Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello. I have a Dataset with two string columns. Only one column has a string for each row. In this string is some text and somewhere in this text is a 7 digit number, either split with a widespace or not split at all. How can I parse the string to find the digits?
Solved! Go to Solution.
Quick thought - this will leave you with errors if the field doesn't contain a 7 digit number. Use try and otherwise to leave the field blank if not found:
try List.Select(List.Transform(Text.Split([Column1], " "), each Text.Select(_, {"0".."9"})), each Text.Length(_) = 7){0}
otherwise ""
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
pls try this
Hi,
You could try something like this in a custom column in Power Query, just change Column1 to your Column Name:
List.Select(List.Transform(Text.Split([Column1], " "), each Text.Select(_, {"0".."9"})), each Text.Length(_) = 7){0}
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
Quick thought - this will leave you with errors if the field doesn't contain a 7 digit number. Use try and otherwise to leave the field blank if not found:
try List.Select(List.Transform(Text.Split([Column1], " "), each Text.Select(_, {"0".."9"})), each Text.Length(_) = 7){0}
otherwise ""
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
Thanks, now there was actually a condition I didn't think of, what if the series of digits can only be 7 digits long and there are bits that are longer than 7 and the code shouldn't catch?
The current formula will only catch the 7 digits if you wanted to modify to capture all digits on the first occurance of digits you could change the = 7 to >0:
try List.Select(List.Transform(Text.Split([Column1], " "), each Text.Select(_, {"0".."9"})), each Text.Length(_) >0){0}
otherwise ""
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 51 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 70 | |
| 64 | |
| 39 | |
| 33 | |
| 23 |