I have a column containing values that I need to split by delimiter and then rearrange + combine.
Instead of doing this in multiple steps by splitting values into multiple columns and then combine them, I'm trying to write my code in a more compact way.
Here's my code, which includes data to create the source table, and my attempt:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKskoSk3Vz89L1S8pz1eKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TextToRearrange = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"TextToRearrange", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "rearranged", each Text.BetweenDelimiters([TextToRearrange],"/") & Text.AfterDelimiter([TextToRearrange], "/",1) & Text.BeforeDelimiter([TextToRearrange],"/"))
in
#"Added Custom"
My expected result is that the first cell should have a value of one/two/three.
But I can't seem to figure out how to feed the text.delimiter functions into the expression. I've tried using Text.Combine to no avail as well.
One way to rearrange in powerquery:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKskoSk3Vz89L1S8pz1eKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TextToRearrange = _t]),
#"Added Custom" = Table.AddColumn(Source, "rearranged", each let a= Text.Split([TextToRearrange],"/") in Text.Combine({a{1},a{2},a{0}},"/") )
in #"Added Custom"