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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
faludigabor
Frequent Visitor

expand column with json content

Hi ,

 

I have a SQL table with columns and one of the columns contain a json string.  I would like to have a flat table ie to expand the column, however the json varies from field to field.

 

 

 

Tx,

gabor

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @faludigabor,

 

Since your json files don't have the uniform fields, you need more work based on the idea of @MarkLaf. Please try it out in this file.

1. Add a customer column with the following formula.

Json.Document([Column2])

expand_column_with_json_content

2. Add the following statement to retrieve all the fields of all the jsons in the Advanced Editor.

#"Expanded Column1" = 
Table.ExpandRecordColumn(#"Added Custom", 
"Custom", 
{"premise_zipcode", "city", "address", "need_invoice","bankcard_number", "seat_zipcode", "note"},
 {"premise_zipcode", "city", "address", "need_invoice","bankcard_number", "seat_zipcode", "note"})

expand_column_with_json_content2

It's easy to replace the NULLs and Errors.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MarkLaf
Solution Sage
Solution Sage

Add a custom column and enter the following:

Json.Document([metadata])

If you are worried about errors (e.g. from instances of [] etc.), you can use the following:

try Json.Document([metadata]) otherwise null

The resulting custom column can be expanded.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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