Forum Discussion
Kagliostro
1 year agoFrequent Visitor
Sort text in a single cell
Hi everyone, I am would like to sort out text in a single cell and to do so I found in this forum a script in M which would fit perfectly with my need (link). However, while the majority of cells wo...
- 1 year ago
There shouldn't be an error, but try this code anyway
=[ f = (x) => Text.Combine(List.Sort(List.Transform(Text.Split(x, ","), Text.Trim)), ","), Split = try f([NAME_ASSIGNED]) otherwise [NAME_ASSIGNED] ][Split]
lbendlin
1 year agoSuper User
There should not be an error, and there is no need to treat a single item list differently.
let
Source = Table.FromRows(
Json.Document(
Binary.Decompress(
Binary.FromText("i45W8s9L1VEIKc/XUVBQcMssS1WK1YlWCskoSgWyYgE=", BinaryEncoding.Base64),
Compression.Deflate
)
),
let
_t = ((type nullable text) meta [Serialized.Text = true])
in
type table [NAME_ASSIGNED = _t]
),
#"Added Custom" = Table.AddColumn(
Source,
"Custom",
each
let
Split = Text.Split([NAME_ASSIGNED], ","),
Trim = List.Transform(Split, each Text.Trim(_)),
Sort = List.Sort(Trim),
Combine = Text.Combine(Sort, ",")
in
Combine
)
in
#"Added Custom"
What's the error message?