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

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

Reply
arnamq
Regular Visitor

How to extract list from a record field from a list to table

Hi,


I have a following JSON:

 

[
  {
    "timestamp": "2019-08-07T09:41:32.000Z",
    "result": [
      {
        "site_name": "x",
        "count_distinct__z": 1948.305445666293,
        "count_distinct__v": 250565.23678795504
      },
      {
        "site_name": "y",
        "count_distinct__z": 1948.305445666293,
        "count_distinct__v": 3889974.5781805683
      }
    ]
  }
]

...and I want to extract the "result" list as a table. I can extract record from the JOSN as:

 

timestamp2019-08-07T09:41:32.000Z
resultList

 

...but I can't expand the "List" as a table.


Kind regards,

Piotr

 

2 ACCEPTED SOLUTIONS
Mariusz
Community Champion
Community Champion

Hi @arnamq 

 

Not sure if I understand what you need, but is this what you after?

please see the attached.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

Hi @arnamq ,

I created a sample to implement it. You could follow the steps.

  • Convert list to a table >  Then expend the columns

1.PNG

Here is the script.

let
    Source = Json.Document(File.Contents("C:\Users\xueding\Desktop\821632.json")),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"timestamp", "result"}, {"Column1.timestamp", "Column1.result"}),
    #"Expanded Column1.result" = Table.ExpandListColumn(#"Expanded Column1", "Column1.result"),
    #"Expanded Column1.result1" = Table.ExpandRecordColumn(#"Expanded Column1.result", "Column1.result", {"site_name", "count_distinct__z", "count_distinct__v"}, {"Column1.result.site_name", "Column1.result.count_distinct__z", "Column1.result.count_distinct__v"})
in
    #"Expanded Column1.result1"

2.PNG

I attached the sample that you can try and check if it is what you want.

 

Edit:

Attach my sample.  (I find I didn't attach it. )

 

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
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

7 REPLIES 7
Mariusz
Community Champion
Community Champion

Hi @arnamq 

 

I've attached the file with a solution, all you need to do is follow the query steps.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Thank you for a quick response 🙂

 

One more question: is it possible to do similar transformation without using expliced declaration of the columnt names?

 

Depending on the query count and names of a result columns may by different.

 

Kind regards,

Piotr

Mariusz
Community Champion
Community Champion

Hi @arnamq 

 

Not sure if I understand what you need, but is this what you after?

please see the attached.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

//Not sure if I understand what you need, but is this what you after?

 

No, not exacly but we're close. I mean a situation when the result schema is unknown before running the query. We can skip the "timestamp" field hance that it is constant and focus on the "result" list. Once it may be:

 

[
  {
    "timestamp": "2019-08-07T09:41:32.000Z",
    "result": [
      {
        "site_name": "x",
        "count_distinct__z": 1948.305445666293,
        "count_distinct__v": 250565.23678795504
      },
      {
        "site_name": "y",
        "count_distinct__z": 1948.305445666293,
        "count_distinct__v": 3889974.5781805683
      }
    ]
  }
]

once

[
  {
    "timestamp": "2019-08-07T09:41:32.000Z",
    "result": [
      {
        "site_name": "x",
        "x": 1948.305445666293,
        "z": 250565.23678795504,
        "a": 1948.305445666293,
        "b": 3889974.5781805683
      },
      {
        "site_name": "y",
        "x": 1948.305445666293,
        "z": 3889974.5781805683,
        "a": 1948.305445666293,
        "b": 3889974.5781805683
      }
    ]
  }
]

and another time it may be:

 

[
  {
    "timestamp": "2019-08-07T09:41:32.000Z",
    "result": [
      {
        "animal" : "frog"
      },
      {
        "animal" : "lion"
      }
    ]
  }
]

 and another time it may be something else 🙂

 

Kind regards,

Piotr

Mariusz
Community Champion
Community Champion

Hi Piotr ( @arnamq )   

 

Try the attached 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Now in the second step ( #"Converted to Table1" = Record.ToTable(Source),) I have: we cannot convert a value of type List to type Record.

 

I'm using the same JSON source as previously:

[
  {
    "timestamp": "2019-08-07T09:41:32.000Z",
    "result": [
      {
        "site_name": "x",
        "count_distinct__z": 1948.305445666293,
        "count_distinct__v": 250565.23678795504
      },
      {
        "site_name": "y",
        "count_distinct__z": 1948.305445666293,
        "count_distinct__v": 3889974.5781805683
      }
    ]
  }
]

Hi @arnamq ,

I created a sample to implement it. You could follow the steps.

  • Convert list to a table >  Then expend the columns

1.PNG

Here is the script.

let
    Source = Json.Document(File.Contents("C:\Users\xueding\Desktop\821632.json")),
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"timestamp", "result"}, {"Column1.timestamp", "Column1.result"}),
    #"Expanded Column1.result" = Table.ExpandListColumn(#"Expanded Column1", "Column1.result"),
    #"Expanded Column1.result1" = Table.ExpandRecordColumn(#"Expanded Column1.result", "Column1.result", {"site_name", "count_distinct__z", "count_distinct__v"}, {"Column1.result.site_name", "Column1.result.count_distinct__z", "Column1.result.count_distinct__v"})
in
    #"Expanded Column1.result1"

2.PNG

I attached the sample that you can try and check if it is what you want.

 

Edit:

Attach my sample.  (I find I didn't attach it. )

 

Best Regards,

Xue Ding

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

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.