Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not 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, col2, col3, json
A, 1, c, {"col1":"A","col2":1,"col3":"c"}
B, 2, d, {"col1":"B","col2":2,"col3":"d"}

thanks

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

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
    addJson

 

 

Example query output:

BA_Pete_0-1713279040647.png

 

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



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

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
    addJson

 

 

Example query output:

BA_Pete_0-1713279040647.png

 

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



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors