cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User II
Super User II

Convert json List Record to Table value

Hi,

 

I'm totally new to Power BI so I'm tried different approached to convert my JSON file to a table but unsuccessful so far.

 

This is my JSON File

 

 

{
    "Family": [
        {
            "Father": "F1",
            "Age": 50,
            "Mother": "M1",
            "MAge": 49,
            "Children": [
                {
                    "Name": "C1"
                },
                {
                    "Name": "C2"
                }
            ]
        },
        {
            "Father": "F2",
            "Age": 55,
            "Mother": "M2",
            "MAge": 53,
            "Children": [
                {
                    "Name": "Cc1"
                },
                {
                    "Name": "Cc2"
                }
            ]
        }
    ]
}

 

 

I want this to be a table like below

 

 
Father    Age      Mother    MAge
F1         50        M1        49

F2         55        M2        53

 

I tried like convert table and transpose which is not working I always getting error like Expression.Error: We cannot convert a value of type Record to type

 

Please help me to get solve this

 

Thanks !

Jay







Did my reply helpful to you ? Please give Kudos

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Convert json List Record to Table value

@Jayendran 

 

You can use this

 

let
    Source = Json.Document(File.Contents("C:\Users\hp\Desktop\File.JSON")),
    Family = Source[Family],
    #"Converted to Table" = Table.FromList(Family, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Father", "Age", "Mother", "MAge", "Children"}, {"Father", "Age", "Mother", "MAge", "Children"})
in
    #"Expanded Column1"

 

Please see attached files as well

Try my new Power BI game Cross the River

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Convert json List Record to Table value

@Jayendran 

 

You can use this

 

let
    Source = Json.Document(File.Contents("C:\Users\hp\Desktop\File.JSON")),
    Family = Source[Family],
    #"Converted to Table" = Table.FromList(Family, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Father", "Age", "Mother", "MAge", "Children"}, {"Father", "Age", "Mother", "MAge", "Children"})
in
    #"Expanded Column1"

 

Please see attached files as well

Try my new Power BI game Cross the River

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Convert json List Record to Table value

Hi Jay,

 

Since you have a standard JSON file, I would suggest you use the built-in connector JSON and follow the steps one by one. The underlying code will be generated by the Query Editor automatically.

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Super User II
Super User II

Re: Convert json List Record to Table value

Thanks for the solution, Actually I'm missing the ExpandRecordColumn Function







Did my reply helpful to you ? Please give Kudos

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors