Forum Discussion
hkbs
5 years agoFrequent Visitor
Sort number within a cell separated by comma Desktop
Sort number within a cell separated by comma Desktop Hi I am hoping that if anyone around can guide me a way on this, I have similar issue of a old post (link below) however involved to cell ex...
- 5 years ago
Sure,
you have to transform to number in order to get the sort right and then back to text in order to combine them in once field again:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTQMTTVMdIx0zHXsdAxUIrVAYpZ6hiZ6BgaAwXAUkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Sort DESC", each Text.Combine(List.Transform(List.Sort(List.Transform(Text.Split([Value],","), Number.From),Order.Descending), Text.From),",")) in #"Added Custom"
amitchandak
Super User
5 years agoImkeF , can you help with this?
ImkeF
Community Champion
5 years agoSure,
you have to transform to number in order to get the sort right and then back to text in order to combine them in once field again:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTQMTTVMdIx0zHXsdAxUIrVAYpZ6hiZ6BgaAwXAUkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Sort DESC", each Text.Combine(List.Transform(List.Sort(List.Transform(Text.Split([Value],","), Number.From),Order.Descending), Text.From),","))
in
#"Added Custom"