【问题标题】:Expand List to same row in Power Query将列表展开到 Power Query 中的同一行
【发布时间】:2021-02-10 01:17:39
【问题描述】:

我是电源查询的新手。我正在解析 JSON。当我使用 Power Query 扩展它时,我有一个数组名称为“类别”,它为每个类别创建三行,而我只想保留一行并想为每个类别创建 3 个单独的列,如 category1、category2、category3。

这是我的代码

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"no", type text}, {"complete", Int64.Type}, {"json", type text}}),
    #"Parsed JSON" = Table.TransformColumns(#"Changed Type",{{"json", Json.Document}}),
    #"Expanded json" = Table.ExpandRecordColumn(#"Parsed JSON", "json", {"title", "price", "StoreName", "ratings", "merchant", "categories", "VariantB", "detailA", "detailB", "bullets", "images", "description"}, {"title", "price", "StoreName", "ratings", "merchant", "categories", "VariantB", "detailA", "detailB", "bullets", "images", "description"})
in
    #"Expanded json"


【问题讨论】:

    标签: powerquery


    【解决方案1】:

    添加额外步骤:

    ExtractList = Table.TransformColumns(#"Expanded json", {"categories", each Text.Combine(List.Transform(_, Text.From), ","), type text})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-25
      • 1970-01-01
      相关资源
      最近更新 更多