Forum Discussion
Convert key in text to Integer for optimization
- Anonymous2 years ago
Hi,
Thanks for the solution Anand24 provided, and i want to offer some more information for user to refer to.
hello Omega , you can create a custom column.
let ListChars = Text.ToList([your column name]), ListNumbers = List.Transform(ListChars, each Character.ToNumber(_)), HashNumber = List.Accumulate(ListNumbers, 0, (state, current) => Number.Mod((state * 31 + current), 9223372036854775807)) in HashNumberOutput
You can also refer to the following code in advanced editor.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCg12jHd29Il3MzE0MjFUitVBEnI3BoqBhZwd/eL9/ULi3dyMDS2NIMocnZxd3dyVYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let ListChars = Text.ToList([Column1]), ListNumbers = List.Transform(ListChars, each Character.ToNumber(_)), HashNumber = List.Accumulate(ListNumbers, 0, (state, current) => Number.Mod((state * 31 + current), 9223372036854775807)) in HashNumber), #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}}) in #"Changed Type1"Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for the solution Anand24 provided, and i want to offer some more information for user to refer to.
hello Omega , you can create a custom column.
let
ListChars = Text.ToList([your column name]),
ListNumbers = List.Transform(ListChars,
each Character.ToNumber(_)),
HashNumber = List.Accumulate(ListNumbers,
0,
(state, current) =>
Number.Mod((state * 31 + current), 9223372036854775807))
in
HashNumber
Output
You can also refer to the following code in advanced editor.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCg12jHd29Il3MzE0MjFUitVBEnI3BoqBhZwd/eL9/ULi3dyMDS2NIMocnZxd3dyVYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let
ListChars = Text.ToList([Column1]),
ListNumbers = List.Transform(ListChars,
each Character.ToNumber(_)),
HashNumber = List.Accumulate(ListNumbers,
0,
(state, current) =>
Number.Mod((state * 31 + current), 9223372036854775807))
in
HashNumber),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}})
in
#"Changed Type1"
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is what I'm looking for. How can I do the same with calculated column?