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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ariten
Frequent Visitor

JSON with columns and rows separate that cant be merged into 1 combined row

Hi All, 

 

Hoping you may be able to help me here. 

 

I have data that i am pulling via a web request, however due to the structure of the data i am having a hard time extracting out the rows and columns, im stuck and have tried multiple different ways. 

 

The data structure is pictured below. 

ariten_0-1672271471345.png

 

This data is psuedo but is representive of the strucuture i am dealing with (10  Columns instead of 4). I am able to extract the column headers out and transpose them into headers, however i am having a issue with the rows, I cant get them to into the list of 4 sperorate columns to reprsent the row to then extract the value for each record. When i try and expand the list i all 4 records merged into 1 column. Pictured below. 

ariten_1-1672270911906.png

after extraction

ariten_2-1672270942955.png

I think im missing a step where i should be able to expand the list across multiple columns or do a sort of condition based transpose, i.e row1 gets id 1 etc.

 

Any thoughts?

 

1 ACCEPTED SOLUTION

Hi, @ariten 

Oh..i know you want to convert this list to a column like 4 columns in a table.

This is my test .json file as a sample data:

vyueyunzhmsft_0-1672363001895.png

You can put this in "Advanced Editor" to refer to:

let
    Source = Json.Document(File.Contents("E:\wicresoft_dict\New Text Document.json")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded Columns" = Table.ExpandRecordColumn(#"Converted to Table", "Columns", {"Column"}, {"Columns.Column"}),
    #"Expanded Rows" = Table.ExpandRecordColumn(#"Expanded Columns", "Rows", {"Row"}, {"Rows.Row"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Rows",{{"Columns.Column", "Column"}, {"Rows.Row", "Row"}}),
    RowData = List.Transform(#"Renamed Columns"[Row]{0},(x)=>  List.Transform(x,(y)=>y[ColData]) ),
    ColumnName = List.Transform(#"Renamed Columns"[Column]{0},(x)=>x[ColTitle]),
    Custom1 = Table.FromRows(RowData,ColumnName)
in
    Custom1

Then we can get the table you want to :

vyueyunzhmsft_1-1672363041287.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

8 REPLIES 8
v-yueyunzh-msft
Community Support
Community Support

Hi, @ariten 

Do you mean you want to filter the list in the [Column1.colData]?

If this , you can use List.Select() function to filter the data you want and then you expand your list .

List.Select - PowerQuery M | Microsoft Learn

 

If this does not help you solve the problem, you can also provide us with some test data and the results you want to generate in the end, so that we can help you better.

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @v-yueyunzh-msft, Thanks for replying. 

ariten_0-1672310734007.png

This is a anonomysed data pull from the source. List.Select is not what im looking for, i need to be able to expand these rows across multiple columns and PowerBi is just recogniseing them as 1 column

Hi, @ariten 

Oh..i know you want to convert this list to a column like 4 columns in a table.

This is my test .json file as a sample data:

vyueyunzhmsft_0-1672363001895.png

You can put this in "Advanced Editor" to refer to:

let
    Source = Json.Document(File.Contents("E:\wicresoft_dict\New Text Document.json")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded Columns" = Table.ExpandRecordColumn(#"Converted to Table", "Columns", {"Column"}, {"Columns.Column"}),
    #"Expanded Rows" = Table.ExpandRecordColumn(#"Expanded Columns", "Rows", {"Row"}, {"Rows.Row"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Rows",{{"Columns.Column", "Column"}, {"Rows.Row", "Row"}}),
    RowData = List.Transform(#"Renamed Columns"[Row]{0},(x)=>  List.Transform(x,(y)=>y[ColData]) ),
    ColumnName = List.Transform(#"Renamed Columns"[Column]{0},(x)=>x[ColTitle]),
    Custom1 = Table.FromRows(RowData,ColumnName)
in
    Custom1

Then we can get the table you want to :

vyueyunzhmsft_1-1672363041287.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi there. I have the same problem to solve, but my JSON structure is different. I've tried to amend it to my use case but can't get it to work. Please help. An generic example of my data structure:

 

 

 

{
    "DataSource": {
        "Name": "Example Data",
        "Headers": [
            {
                "Name": "Column 1",
                "Type": "Text"
            },
            {
                "Name": "Column 2",
                "Type": "Text"
            },
            {
                "Name": "Column 3",
                "Type": "Text"
            },
            {
                "Name": "Column 4",
                "Type": "Text"
            }
        ],
        "Rows": [
            [
                "123-Test",
                "Test",
                "Test",
                "Test"
            ],
            [
                "234-Test",
                "Test",
                "Test",
                "Test"
            ],
            [
                "345-Test",
                "Test",
                "Test",
                "Test"
            ],
            [
                "456-Test",
                "Test",
                "Test",
                "Test"
            ]
        ],
        "TotalRows": 4
    }
}

 

 

I need this to output: 

 

Column 1Column 2Column 3Column 4
123-TestTestTestTest
234-TestTestTestTest
345-TestTestTestTest
456-TestTestTestTest

Hi @Steve_ABC & @Damien25 

 

Please try 

let
    Source = Json.Document(File.Contents("C:\Users\Public\test.json")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"DataSource" = #"Converted to Table"{0}[DataSource],
    #"Headers" = List.Transform(#"DataSource"[Headers],(x)=>x[Name]),
    Custom1 = Table.FromRows(#"DataSource"[Rows],#"Headers")
in
    Custom1

Replace the Source section with your data source. 

 

This is outputting the tbale in the format you were looking for. 

ariten_0-1708041969102.png

 

Hi @Steve_ABC 

I'm facing same json schema structure and I'm not able to figure it out. Would you have an example to share that match your schema above?

Thanks,
D.

Thanks this got me on the right track, had to make 1 very small change to account for difference in our structures but it all works now, Thanks!

ariten_0-1672613534242.png

 

ariten
Frequent Visitor

Point of clarification in my data structure, Row is a list of Records, these records contain the field ColData which contains a list of records which have a field called "value" that the value of that cell. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.