How to split JSON columns in Power BI

元气小坏坏 提交于 2019-12-11 07:28:00

问题


I have imported JSON data from Hive database. The structure looks like the attached. JSON data has been dumped to Hive without normalizing. Is it possible to parse the data?. For example, in the attached image, the mentionedlocations column has some places mentioned and I want them to be in separate rows.


回答1:


You can use the Json.Document function to read the column as JSON.

I'd suggest creating a custom column with this formula:

Record.ToTable(Json.Document([mentionedlocations]))

and then expanding that column to get the multiple rows you want.


Putting these together:

= Table.ExpandTableColumn(
      Table.AddColumn(PreviousStep, "Custom",
          each Record.ToTable(Json.Document([mentionedlocations]))),
      "Custom", {"Name"}, {"locations"})

This takes the PreviousStep in the query, adds a Custom column which converts the JSON text into a table and then expands the Name column in each of the tables in the Custom column and renames the column locations.



来源:https://stackoverflow.com/questions/50577136/how-to-split-json-columns-in-power-bi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!