Forum Discussion
Anonymous
5 years agoNot applicable
Extract Using Any Non-Number As Delimiter
Hi. I am trying to extract numbers that only exist before any characters occur in the string. Once ANY characters start, that will be the end of the number. The trick here is that somtimes there are ...
- Anonymous5 years ago
= Table.AddColumn(#"Modificato tipo", "Personalizzato", each try Number.From(Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => c <"0" or c>"9")([Source]){0}) otherwise 1) - 5 years ago
Anonymous , you need to add a new column this way in your senario,
Jimmy801
5 years agoCommunity Champion
Hello Anonymous
you can use this formula in a new column
let GetNumber= List.FirstN(Text.ToList(_[Source]), (itemlist)=> Value.Is(try Number.From(itemlist) otherwise "text",type number) ) in if List.IsEmpty(GetNumber) then 1 else Number.From(Text.Combine(GetNumber))
here a complete example
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjZQitWJVjIxcATThkY6ps4+QWC2o5MzjDY0MlaKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Source = _t]),
AddColumn = Table.AddColumn
(
Source,
"Extract",
each let GetNumber= List.FirstN(Text.ToList(_[Source]), (itemlist)=> Value.Is(try Number.From(itemlist) otherwise "text",type number) ) in if List.IsEmpty(GetNumber) then 1 else Number.From(Text.Combine(GetNumber))
)
in
AddColumn
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy