Forum Discussion
Transform.Columns with TextCombine
- 5 years ago
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRcgRiU6VYnWilJCALiEqKSlPBfGcgJwWIXdPSlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [stringField1 = _t, stringField2 = _t, other = _t]), Transformed = List.Accumulate({"stringField1","stringField2"}, Source, (s,c) => Table.TransformColumns(s, {c, each if Text.Length(_)=0 then null else """"&_&""""})) in Transformed
Thanks CNENFRNL that's the result I've expected.
But to be honest, this is not as straight forward as I've tought it will be.
Apreciating your support and as a learner I would like to understand your solution to have a (modest) chance to transfer this into new areas and to annoy you again (and again...).
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRcgRiU6VYnWilJCALiEqKSlPBfGcgJwWIXdPSlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)),
I think the first part of the line creates just the table as shown and the fun part starts from here:
let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [stringField1 = _t, stringField2 = _t, other = _t]),
What does this do? Can you pass me a #tag or a link for further info?
text
Transformed = List.Accumulate({"stringField1","stringField2"}, Source, (s,c) => Table.TransformColumns(s, {c, each if Text.Length(_)=0 then null else """"&_&""""}))
in
Transformed
List Accumulate is executed in the List {} that contains StringField1 and stringField2.
the second parameter is the "seed", so seed is the previous step "Source".
the accumulator is then the third parameter that is built with the function Table.TransformColumns, where conditonally _ is cocantenated with double quotes.
Here I just don't understand the utilization of the parameters s,c and _?
Where do they come from? Do you have any links for further info sources on these?
At least the Table.TransformColumns help page does not tell how to do it.
Thanks again and in advance for any support.
Best M
Hi, there. So glad my proposal helps. As to those details, it requires some general understanding of the M language. I recommend this series of blogs as a primer,
in fact, thanks to this series, I got familiar with this fanscinating language.