Forum Discussion
Parse JSON String in column
Hi,
How is possible to parse JSON string in the column to several columns?
6 Replies
- mahoneypatMicrosoft Employee
You should be able to use the Json.Document function to parse the JSON. Depending on the structure, you will likely be able to expand the contained Records and/or Lists.
Regards,
Pat
- Jimmy801Community Champion
Hello Anonymous
you can use Table.TransformColumns or even better Table.TransformRows to loop through your data and applying a Json.Document on every cell. Surround it by try otherwise to handle empty rows or non-json-cells
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy - v-alq-msftCommunity Support
Hi, Anonymous
You may try adding a new step with the following m codes.
=Table.TransformColumns(#"Last Step",{{"device",Json.Document},{"geo",Json.Document}, {"app_info",Json.Document}})Then you may expand the column to get the corresponding result.
For further information, please refer to the following link.
Convert JSON strings to tables in Power Query/ Power BI
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- CNENFRNLCommunity Champion
Hi, v-alq-msft , you might want to simply the code this way if the table consists of too many columns
= Function.Invoke(Table.TransformColumns, {#"Last Step", List.Accumulate(Table.ColumnNames(#"Last Step"), {}, (s,c)=>s&{{c,Json.Document}})}) - AnonymousNot applicable
Hi,
Where I need to add "New Step"?- v-alq-msftCommunity Support
Hi, Anonymous
You may right click the last step of the query and click 'Insert Step After' like below.
Best Regards
Allan