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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DanielV91
Frequent Visitor

Can I achieve this with JSON

I have the following JSON but with more products

{
  "products": [
    {
      "product": "Tank Toy",
      "progress": "done",
      "components": [
        {
          "self": "https://dummy.com/1",
          "id": "1",
          "name": "plastic"
        },
        {
          "self": "https://dummy.com/2",
          "id": "2",
          "name": "metal"
        },
        {
          "self": "https://dummy.com/5",
          "id": "5",
          "name": "polyurethane"
        }
      ],
      "id": "100"
    },
    {
      "product": "Car Toy",
      "progress": "in progress",
      "components": [
        {
          "self": "https://dummy.com/6",
          "id": "6",
          "name": "polycarbonate"
        },
        {
          "self": "https://dummy.com/12",
          "id": "12",
          "name": "aluminium"
        }
      ],
      "id": "23"
    },
    {
      "product": "Doll Toy",
      "progress": "done",
      "components": [
        {
          "self": "https://dummy.com/11",
          "id": "6",
          "name": "Polystyrene"
        }
      ],
      "id": "40"
    }
  ]
}

I am interested into generating a table like this

productprogresscomponentsid
Tank Toydoneplastic,metal,polyurethane100
Car Toyin progresspolycarbonate,aluminium23
Doll Toydonepolystyrene40

 

As you can see the only thing that is bugging me is how can I join all the components name into a single cell. I am only interested in the names in the components array. It is bugging me that a product can have multiple components. I couldn't make it work and I want to know if it is possible. 

If somebody has an idea I would gladly appreciate

3 ACCEPTED SOLUTIONS
DanielV91
Frequent Visitor

Eric_Zhang
Microsoft Employee
Microsoft Employee

@DanielV91

I'd suggest extract the JSON in below format, as it is more normalized.

Capture.PNG

let
    Source = Json.Document("{
  ""products"": [
    {
      ""product"": ""Tank Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/1"",
          ""id"": ""1"",
          ""name"": ""plastic""
        },
        {
          ""self"": ""https://dummy.com/2"",
          ""id"": ""2"",
          ""name"": ""metal""
        },
        {
          ""self"": ""https://dummy.com/5"",
          ""id"": ""5"",
          ""name"": ""polyurethane""
        }
      ],
      ""id"": ""100""
    },
    {
      ""product"": ""Car Toy"",
      ""progress"": ""in progress"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/6"",
          ""id"": ""6"",
          ""name"": ""polycarbonate""
        },
        {
          ""self"": ""https://dummy.com/12"",
          ""id"": ""12"",
          ""name"": ""aluminium""
        }
      ],
      ""id"": ""23""
    },
    {
      ""product"": ""Doll Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/11"",
          ""id"": ""6"",
          ""name"": ""Polystyrene""
        }
      ],
      ""id"": ""40""
    }
  ]
}"),
    products = Source[products],
    #"Converted to Table" = Table.FromList(products, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"product", "progress", "components", "id"}, {"Column1.product", "Column1.progress", "Column1.components", "Column1.id"}),
    #"Expanded Column1.components" = Table.ExpandListColumn(#"Expanded Column1", "Column1.components"),
    #"Expanded Column1.components1" = Table.ExpandRecordColumn(#"Expanded Column1.components", "Column1.components", {"name"}, {"Column1.components.name"})
in
    #"Expanded Column1.components1"

For the case in your Post.

Capture.PNG

 

let
    Source = Json.Document("{
  ""products"": [
    {
      ""product"": ""Tank Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/1"",
          ""id"": ""1"",
          ""name"": ""plastic""
        },
        {
          ""self"": ""https://dummy.com/2"",
          ""id"": ""2"",
          ""name"": ""metal""
        },
        {
          ""self"": ""https://dummy.com/5"",
          ""id"": ""5"",
          ""name"": ""polyurethane""
        }
      ],
      ""id"": ""100""
    },
    {
      ""product"": ""Car Toy"",
      ""progress"": ""in progress"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/6"",
          ""id"": ""6"",
          ""name"": ""polycarbonate""
        },
        {
          ""self"": ""https://dummy.com/12"",
          ""id"": ""12"",
          ""name"": ""aluminium""
        }
      ],
      ""id"": ""23""
    },
    {
      ""product"": ""Doll Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/11"",
          ""id"": ""6"",
          ""name"": ""Polystyrene""
        }
      ],
      ""id"": ""40""
    }
  ]
}"),
    products = Source[products],
    #"Converted to Table" = Table.FromList(products, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"product", "progress", "components", "id"}, {"Column1.product", "Column1.progress", "Column1.components", "Column1.id"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Column1", "Custom", each Text.Combine(Table.ToList(Table.SelectColumns(Table.FromList([Column1.components],Record.FieldValues, {"self", "id", "Name"}),"Name")),",")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Text.Combine([Custom],each Text.From(_))),
    #"Column1 components" = #"Added Custom1"{0}[Column1.components]
in
    #"Column1 components"

 

View solution in original post

Thank you very much for helping @Eric_Zhang Sorry I couldn't reply faster.

View solution in original post

3 REPLIES 3
Eric_Zhang
Microsoft Employee
Microsoft Employee

@DanielV91

I'd suggest extract the JSON in below format, as it is more normalized.

Capture.PNG

let
    Source = Json.Document("{
  ""products"": [
    {
      ""product"": ""Tank Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/1"",
          ""id"": ""1"",
          ""name"": ""plastic""
        },
        {
          ""self"": ""https://dummy.com/2"",
          ""id"": ""2"",
          ""name"": ""metal""
        },
        {
          ""self"": ""https://dummy.com/5"",
          ""id"": ""5"",
          ""name"": ""polyurethane""
        }
      ],
      ""id"": ""100""
    },
    {
      ""product"": ""Car Toy"",
      ""progress"": ""in progress"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/6"",
          ""id"": ""6"",
          ""name"": ""polycarbonate""
        },
        {
          ""self"": ""https://dummy.com/12"",
          ""id"": ""12"",
          ""name"": ""aluminium""
        }
      ],
      ""id"": ""23""
    },
    {
      ""product"": ""Doll Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/11"",
          ""id"": ""6"",
          ""name"": ""Polystyrene""
        }
      ],
      ""id"": ""40""
    }
  ]
}"),
    products = Source[products],
    #"Converted to Table" = Table.FromList(products, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"product", "progress", "components", "id"}, {"Column1.product", "Column1.progress", "Column1.components", "Column1.id"}),
    #"Expanded Column1.components" = Table.ExpandListColumn(#"Expanded Column1", "Column1.components"),
    #"Expanded Column1.components1" = Table.ExpandRecordColumn(#"Expanded Column1.components", "Column1.components", {"name"}, {"Column1.components.name"})
in
    #"Expanded Column1.components1"

For the case in your Post.

Capture.PNG

 

let
    Source = Json.Document("{
  ""products"": [
    {
      ""product"": ""Tank Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/1"",
          ""id"": ""1"",
          ""name"": ""plastic""
        },
        {
          ""self"": ""https://dummy.com/2"",
          ""id"": ""2"",
          ""name"": ""metal""
        },
        {
          ""self"": ""https://dummy.com/5"",
          ""id"": ""5"",
          ""name"": ""polyurethane""
        }
      ],
      ""id"": ""100""
    },
    {
      ""product"": ""Car Toy"",
      ""progress"": ""in progress"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/6"",
          ""id"": ""6"",
          ""name"": ""polycarbonate""
        },
        {
          ""self"": ""https://dummy.com/12"",
          ""id"": ""12"",
          ""name"": ""aluminium""
        }
      ],
      ""id"": ""23""
    },
    {
      ""product"": ""Doll Toy"",
      ""progress"": ""done"",
      ""components"": [
        {
          ""self"": ""https://dummy.com/11"",
          ""id"": ""6"",
          ""name"": ""Polystyrene""
        }
      ],
      ""id"": ""40""
    }
  ]
}"),
    products = Source[products],
    #"Converted to Table" = Table.FromList(products, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"product", "progress", "components", "id"}, {"Column1.product", "Column1.progress", "Column1.components", "Column1.id"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Column1", "Custom", each Text.Combine(Table.ToList(Table.SelectColumns(Table.FromList([Column1.components],Record.FieldValues, {"self", "id", "Name"}),"Name")),",")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Text.Combine([Custom],each Text.From(_))),
    #"Column1 components" = #"Added Custom1"{0}[Column1.components]
in
    #"Column1 components"

 

Thank you very much for helping @Eric_Zhang Sorry I couldn't reply faster.
DanielV91
Frequent Visitor

Any advise?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors
Top Kudoed Authors