Powerquery 遍历步骤列表

Powerquery iterate over list of steps

我正在使用 excel powerquery 从 elasticsearch 中提取数据。 一个结果工作正常,但我想得到很多。从最初的 ES 查询中,我得到了一个 json 对象的列表,我可以很容易地将其转换为我想要的 table。 问题是查询编辑器只让我 select 一个接一个地得到结果,而不是解析列表中的所有内容。

查询是:

let

    Content = "{""query"": {""match_all"": {}}}",
    Source = Json.Document(Web.Contents("http://es_host:9200/lcm_db/_search"))[hits][hits],
    Source1 = Source{1},
    _source = Source1[_source],
    #"Converted to Table" = Record.ToTable(_source),
    #"Transposed Table" = Table.Transpose(#"Converted to Table")
in
    #"Transposed Table"

Json.Document(Web.Contents("http://es_host:9200/lcm_db/_search"))[hits][hits]

给我一个列表,我必须为此执行 4 个步骤:

Source1 = Source{1},
_source = Source1[_source],
#"Converted to Table" = Record.ToTable(_source),
#"Transposed Table" = Table.Transpose(#"Converted to Table")

我如何让 powerquery 对所有列表结果执行这四个步骤?

谢谢, 艾萨克

您可以使用 List.Transform,并将这 4 个步骤包含在 let 语句中。它看起来像:

= List.Transform(Json.Document(Web.Contents("http://es_host:9200/lcm_db/_search"))[hits][hits], (value) => each
    let
        _source = value[_source],
        #"Converted to Table" = Record.ToTable(_source),
        #"Transposed Table" = Table.Transpose(#"Converted to Table")
    in
        #"Transposed Table")