如何在 Power BI 中拆分 JSON 列 [英] How to split JSON columns in Power BI

查看:26
本文介绍了如何在 Power BI 中拆分 JSON 列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已从 Hive 数据库导入 JSON 数据.该结构看起来像附件.JSON 数据已转储到 Hive 而不进行规范化.是否可以解析数据?例如,在所附图像中,提到的位置 列中提到了一些地方,我希望它们位于单独的行中.

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.

推荐答案

您可以使用 Json.Document 函数 以 JSON 格式读取列.

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.

把这些放在一起:

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

这需要查询中的 PreviousStep,添加一个 Custom 列,该列将 JSON 文本转换为表格,然后扩展 Name 列在 Custom 列中的每个表中,并将列重命名为 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.

这篇关于如何在 Power BI 中拆分 JSON 列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆