Forum Discussion
Anonymous
2 years agoNot applicable
Json format of each record
Hi all, I have a csv file with a huge number of records, when loaded into powe query, I need to add a new custom column that contains the json representation of each record as follows : col1, c...
- 2 years ago
Hi Anonymous ,
Try this example query by pasting into a new blank query in Advanced Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIE4mSlWJ1oJScgywiIU5RiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Col1 = _t, Col2 = _t, Col3 = _t]), addJson = Table.AddColumn( Source, "json", each Text.FromBinary( Json.FromValue( [ [Col1], [Col2], [Col3] ] ) ) ) in addJsonExample query output:
To add as a custom column to your existing query, just use this bit of the code in the column formula:
Text.FromBinary( Json.FromValue( [ [Col1], [Col2], [Col3] ] ) )Pete
BA_Pete
Super User
2 years agoHi Anonymous ,
Try this example query by pasting into a new blank query in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIE4mSlWJ1oJScgywiIU5RiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Col1 = _t, Col2 = _t, Col3 = _t]),
addJson =
Table.AddColumn(
Source,
"json",
each Text.FromBinary(
Json.FromValue(
[
[Col1],
[Col2],
[Col3]
]
)
)
)
in
addJson
Example query output:
To add as a custom column to your existing query, just use this bit of the code in the column formula:
Text.FromBinary(
Json.FromValue(
[
[Col1],
[Col2],
[Col3]
]
)
)
Pete