Forum Discussion

Jeze1's avatar
Jeze1
Frequent Visitor
9 months ago
Solved

New to Power Query

Apologies in advance. I am relatively new to Power Query (and coding) and have spent a couple of days looking at forums/guides/etc, and playing with Power Query. I have a JSON file that I have edite...
  • vojtechsima's avatar
    vojtechsima
    9 months ago

    Jeze1 ,

    I mean I built it for your original structure where I expected two items, first is headers, the rest is all rows.

    If your JSON will have first row headers and then N number of rows of items, you can do this:

    let
        Source = Json.Document(File.Contents("path.json")),
        
        headers = List.Transform( Source[Rows]{0}[Cells]?, each [Value] ),
        listWithRows = List.Range( Source[Rows], 1),
        getRows = List.Combine(  List.Transform(listWithRows, (l1)=> List.Transform(l1[Rows], (l2)=> List.Transform(l2[Cells], (l3)=> l3[Value]))) ),
        createTable = #table(headers, getRows)
    in
        createTable


    Since we have one more list, the process is kind of the same, just one level deeper.