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
kbachova
Advocate II
Advocate II

JSON file to table

Hi superusers,

 

I have this JSON file:

 

"{
\"column_definitions\": [
{
\"Database_RecID\": {
\"type\": \"Numeric\",
\"isNullable\": false,
\"identityColumn\": true
}
},
{
\"Index_Number\": {
\"type\": \"Text\",
\"isNullable\": true,
\"identityColumn\": false
}
},
{
\"Support_Type\": {
\"type\": \"Text\",
\"isNullable\": false,
\"identityColumn\": false
}
}
],
\"row_values\": [
[
12303,
\"32255\",
\"Standard\"
],
[
14273,
\"31475\",
\"Optional\"
]
]
}"


and I am unable to convert it into a table. I can either extract the row values or the column values. Any ideas how to make this work, please?

 

The required output is:

 

2020-05-21_0535.png


Thank you!

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @kbachova , 

You could save your above code as json file, then try below M code

let
    Source = Json.Document(File.Contents("C:\Users\<username>\Desktop\gantt.json")),
    #"Parsed JSON" = Json.Document(Source),
    #"Converted to Table" = Record.ToTable(#"Parsed JSON"),
    #"Transposed Table" = Table.Transpose(#"Converted to Table"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Expanded row_values" = Table.ExpandListColumn(#"Promoted Headers", "row_values"),
    #"Extracted Values" = Table.TransformColumns(#"Expanded row_values", {"row_values", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Expanded column_definitions" = Table.ExpandListColumn(#"Extracted Values", "column_definitions"),
    #"Added Custom" = Table.AddColumn(#"Expanded column_definitions", "Custom", each Record.FieldNames([column_definitions])),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values1",{"column_definitions"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"row_values"}, {{"combine", each Text.Combine([Custom], ","), type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 0, 1),
    #"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[combine]), "combine", "row_values"),
    #"Demoted Headers" = Table.DemoteHeaders(#"Pivoted Column"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Demoted Headers", "Column2", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column2.1", "Column2.2", "Column2.3"}),
    #"Promoted Headers1" = Table.PromoteHeaders(#"Split Column by Delimiter", [PromoteAllScalars=true]),
    #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers1",{{"Index", Int64.Type}, {"Database_RecID", Int64.Type}, {"Index_Number", Int64.Type}, {"Support_Type", type text}})
in
    #"Changed Type2"

Best Regards,
Zoe Zhi

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

3 REPLIES 3
dax
Community Support
Community Support

Hi @kbachova , 

You could save your above code as json file, then try below M code

let
    Source = Json.Document(File.Contents("C:\Users\<username>\Desktop\gantt.json")),
    #"Parsed JSON" = Json.Document(Source),
    #"Converted to Table" = Record.ToTable(#"Parsed JSON"),
    #"Transposed Table" = Table.Transpose(#"Converted to Table"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Expanded row_values" = Table.ExpandListColumn(#"Promoted Headers", "row_values"),
    #"Extracted Values" = Table.TransformColumns(#"Expanded row_values", {"row_values", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Expanded column_definitions" = Table.ExpandListColumn(#"Extracted Values", "column_definitions"),
    #"Added Custom" = Table.AddColumn(#"Expanded column_definitions", "Custom", each Record.FieldNames([column_definitions])),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values1",{"column_definitions"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"row_values"}, {{"combine", each Text.Combine([Custom], ","), type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 0, 1),
    #"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[combine]), "combine", "row_values"),
    #"Demoted Headers" = Table.DemoteHeaders(#"Pivoted Column"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Demoted Headers", "Column2", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column2.1", "Column2.2", "Column2.3"}),
    #"Promoted Headers1" = Table.PromoteHeaders(#"Split Column by Delimiter", [PromoteAllScalars=true]),
    #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers1",{{"Index", Int64.Type}, {"Database_RecID", Int64.Type}, {"Index_Number", Int64.Type}, {"Support_Type", type text}})
in
    #"Changed Type2"

Best Regards,
Zoe Zhi

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

@dax Thank you! This worked!

Greg_Deckler
Community Champion
Community Champion

Still doesn't validate as valid JSON.
https://jsonformatter.curiousconcept.com/


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Kudoed Authors