如何在PowerBI中扩展JSON数据?

eqoofvh9  于 2023-03-24  发布在  其他
关注(0)|答案(2)|浏览(204)

我试图在powerBI中读取一个JSON文件,其数据看起来像这样,但当我扩展列www.example.com时timeseries.data,我只能看到'timestamp'列而不是'timestamp'和'average'

"cost":  44639,
    "timespan":  "2023-02-10T23:59:59Z/2023-03-13T23:59:59Z",
    "interval":  "PT1H",
    "value":  [
                  {
                      "id":  "xxxx",
                      "type":  "Microsoft.Insights/metrics",
                      "name":  {
                                   "value":  "UsedCapacity",
                                   "localizedValue":  "Used capacity"
                               },
                      "displayDescription":  "The amount of storage used by the storage account. For standard storage accounts, it\u0027s the sum of capacity used by blob, table, file, and queue. For premium storage accounts and Blob storage accounts, it is the same as BlobCapacity or FileCapacity.",
                      "unit":  "Bytes",
                      "timeseries":  [
                                         {
                                             "metadatavalues":  [

                                                                ],
                                             "data":  [
                                                          {
                                                              "timeStamp":  "2023-02-10T23:59:00Z"
                                                          },
                                                          {
                                                              "timeStamp":  "2023-02-11T00:59:00Z"
                                                          },
                                                          {
                                                              "timeStamp":  "2023-02-11T01:59:00Z"
                                                          },
                                                          {
                                                              "timeStamp":  "2023-02-11T02:59:00Z"
                                                          },
                                                          {
                                                              "timeStamp":  "2023-02-11T03:59:00Z"
                                                          },
                                                          {
                                                              "timeStamp":  "2023-02-11T04:59:00Z"
                                                          },
                                                          {  "timeStamp":  "2023-03-10T06:59:00Z","average": 19148425}  ],
                      "errorCode":  "Success"
                  }
              ],
    "namespace":  "Microsoft.Storage/storageAccounts",
    "resourceregion":  "eastus"

data in powerBI

vuktfyat

vuktfyat1#

看起来前1000条记录不包含average键值对。对于存在average键值对的记录,您可以按原样展开该列,并修改自动生成的公式以同样展开average
您还可以尝试对表重新排序,使前1000个记录中包含average,这样您就可以展开而无需编辑展开时生成的自动代码。

g9icjywg

g9icjywg2#

这是因为扫描的1000行没有平均列。

为了timeseries.data在下一步中将www.example.com扩展为timestamp和average列,您可以按如下方式更改查询。

= Table.ExpandRecordColumn(#"Expanded value.timeseries.data", "value.timeseries.data", {"timeStamp","average"}, 
{"value.timeseries.data.timeStamp","value.timeseries.data.average"})

  • 您可以通过基于列timeseries.data.average对数据进行排序来验证average列中的数据。

相关问题