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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
bienthused
New Member

Extracting Values from Nested Records and Lists

Hello everyone,

 

I am struggling to parse and flatten a list of records with a nested list of records.

 

Ideally, I would like to combine all the information using delimiters into one string of text per each row, but ran into errors using Extract Values and have not had any luck using Text Combine. Field values can be blank, and there is no standardization in number of records in a list. Below is an example of the column in question for one row:

 

 

{
  "RenderingInformation": [
    {
      "RenderingName": "ContentWithImage",
      "RenderingDataSource": "/platform/content/location",
      "IsLocal": true,
      "DataSourceFields": [
        {
          "FieldName": "Title",
          "FieldValue": "Title value"
        },
        {
          "FieldName": "Image",
          "FieldValue": "<image src=\"https://assets.location.com\">"
        },
        {
          "FieldName": "Description",
          "FieldValue": ""
        }
      ]
    },
    {
      "RenderingName": "Cards",
      "RenderingDataSource": "/platform/content/location",
      "IsLocal": true,
      "DataSourceFields": [
        {
          "FieldName": "CardButtonLabel",
          "FieldValue": "Read Now"
        },
        {
          "FieldName": "Card Description",
          "FieldValue": "Description of card."
        }
      ]
    },
    {
      "RenderingName": "Column Splitter",
      "RenderingDataSource": "",
      "IsLocal": false,
      "DataSourceFields": []
    }
  ]
}

 

 

 Desired output: ContentWithImage;/platform/content/location;true;Title - Title value, Image - https://assets.location.com, Description - |Cards;/platform/content/location; ....(etc)

7 REPLIES 7
lbendlin
Super User
Super User

Please repost your desired outcome.  Here is an example of a standard JSON parser.

 

 

let
    Source = "{
  ""RenderingInformation"": [
    {
      ""RenderingName"": ""ContentWithImage"",
      ""RenderingDataSource"": ""/platform/content/location"",
      ""IsLocal"": true,
      ""DataSourceFields"": [
        {
          ""FieldName"": ""Title"",
          ""FieldValue"": ""Title value""
        },
        {
          ""FieldName"": ""Image"",
          ""FieldValue"": ""<image src=\""https://assets.location.com\"">""
        },
        {
          ""FieldName"": ""Description"",
          ""FieldValue"": """"
        }
      ]
    },
    {
      ""RenderingName"": ""Cards"",
      ""RenderingDataSource"": ""/platform/content/location"",
      ""IsLocal"": true,
      ""DataSourceFields"": [
        {
          ""FieldName"": ""CardButtonLabel"",
          ""FieldValue"": ""Read Now""
        },
        {
          ""FieldName"": ""Card Description"",
          ""FieldValue"": ""Description of card.""
        }
      ]
    },
    {
      ""RenderingName"": ""Column Splitter"",
      ""RenderingDataSource"": """",
      ""IsLocal"": false,
      ""DataSourceFields"": []
    }
  ]
}",
    #"Parsed JSON" = Json.Document(Source),
    #"Converted to Table" = Record.ToTable(#"Parsed JSON"),
    #"Expanded Value" = Table.ExpandListColumn(#"Converted to Table", "Value"),
    #"Expanded Value1" = Table.ExpandRecordColumn(#"Expanded Value", "Value", {"RenderingName", "RenderingDataSource", "IsLocal", "DataSourceFields"}, {"RenderingName", "RenderingDataSource", "IsLocal", "DataSourceFields"}),
    #"Expanded DataSourceFields" = Table.ExpandListColumn(#"Expanded Value1", "DataSourceFields"),
    #"Expanded DataSourceFields1" = Table.ExpandRecordColumn(#"Expanded DataSourceFields", "DataSourceFields", {"FieldName", "FieldValue"}, {"FieldName", "FieldValue"})
in
    #"Expanded DataSourceFields1"

which results in

lbendlin_0-1653165056738.png

 

 

For the desired output, I want to have all of the information combined into a single column using delimiters (see above example format). The data source can have any number of records, so using this method would create many unneccessary columns.

Please repost your expected output. It got mangled by the forum due to the HTML tags in your data.  Post a screenshot of the expected outcome.

bienthused_0-1653315064087.png

Here is an example of how I want the string to look in the column.

For example 

 

""FieldValue"": ""<image src=\""https://assets.location.com\"">""

 

does not render correctly in your post because of the HTML tags.  Screenshotting your post will not make it any better.

This is exactly how I want my output, with HTML tags.

let
    Source = "{
  ""RenderingInformation"": [
    {
      ""RenderingName"": ""ContentWithImage"",
      ""RenderingDataSource"": ""/platform/content/location"",
      ""IsLocal"": true,
      ""DataSourceFields"": [
        {
          ""FieldName"": ""Title"",
          ""FieldValue"": ""Title value""
        },
        {
          ""FieldName"": ""Image"",
          ""FieldValue"": ""<image src=\""https://assets.location.com\"">""
        },
        {
          ""FieldName"": ""Description"",
          ""FieldValue"": """"
        }
      ]
    },
    {
      ""RenderingName"": ""Cards"",
      ""RenderingDataSource"": ""/platform/content/location"",
      ""IsLocal"": true,
      ""DataSourceFields"": [
        {
          ""FieldName"": ""CardButtonLabel"",
          ""FieldValue"": ""Read Now""
        },
        {
          ""FieldName"": ""Card Description"",
          ""FieldValue"": ""Description of card.""
        }
      ]
    },
    {
      ""RenderingName"": ""Column Splitter"",
      ""RenderingDataSource"": """",
      ""IsLocal"": false,
      ""DataSourceFields"": []
    }
  ]
}",
    #"Parsed JSON" = Json.Document(Source),
    #"Converted to Table" = Record.ToTable(#"Parsed JSON"),
    #"Expanded Value" = Table.ExpandListColumn(#"Converted to Table", "Value"),
    #"Expanded Value1" = Table.ExpandRecordColumn(#"Expanded Value", "Value", {"RenderingName", "RenderingDataSource", "IsLocal", "DataSourceFields"}, {"RenderingName", "RenderingDataSource", "IsLocal", "DataSourceFields"}),
    #"Expanded DataSourceFields" = Table.ExpandListColumn(#"Expanded Value1", "DataSourceFields"),
    #"Expanded DataSourceFields1" = Table.ExpandRecordColumn(#"Expanded DataSourceFields", "DataSourceFields", {"FieldName", "FieldValue"}, {"FieldName", "FieldValue"}),
    #"Added Custom" = Table.AddColumn(#"Expanded DataSourceFields1", "Result", each [RenderingName] & ";" & [RenderingDataSource] & ";" & Text.From([IsLocal]) & ";" & [FieldName] & ";" & [FieldValue]),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Result"})
in
    #"Removed Other Columns"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors