Forum Discussion
Anonymous
6 years agoNot applicable
split column to get only integers
Hello all, Hope you all doing well. I need your help in my data query. i have a column called ABC with data as follows: Ravi-1 Syntel-42 Phoenix-34 Query-67 Loading... Query-Manipulated...
- 6 years ago
Hi, Anonymous
I;d like to suggest you use Power Query. I created data to reproduce your scenario.
Table:
You may add a new custom column with the following formula.
= Table.AddColumn(#"Changed Type","Result",each if Text.Length (Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."}))=0 then 0 else Number.FromText(Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."})) )Here is my codes in 'advanced editor'.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkosy9Q1VIrViVYKrswrSc3RNTEC8wIy8lPzMit0jU3A3MDS1KJKXTNzMMcnPzElMy9dT08PSc43MS+zoDQnsSQ1BSyanJpXUpSYoxQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ABC = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ABC", type text}}), Custom1 = Table.AddColumn(#"Changed Type","Result",each if Text.Length (Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."}))=0 then 0 else Number.FromText(Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."})) ) in Custom1Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-alq-msft
6 years agoCommunity Support
Hi, Anonymous
I;d like to suggest you use Power Query. I created data to reproduce your scenario.
Table:
You may add a new custom column with the following formula.
= Table.AddColumn(#"Changed Type","Result",each if Text.Length (Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."}))=0 then 0 else Number.FromText(Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."})) )
Here is my codes in 'advanced editor'.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkosy9Q1VIrViVYKrswrSc3RNTEC8wIy8lPzMit0jU3A3MDS1KJKXTNzMMcnPzElMy9dT08PSc43MS+zoDQnsSQ1BSyanJpXUpSYoxQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ABC = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ABC", type text}}),
Custom1 = Table.AddColumn(#"Changed Type","Result",each if Text.Length (Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."}))=0 then 0 else Number.FromText(Text.TrimStart([ABC],{"a".."z","A".."Z"}&{"-","."})) )
in
Custom1
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.