我正在使用 Excel powerquery 从 Elasticsearch 中提取数据。 对于一个结果来说效果很好,但我想得到很多结果。从最初的 ES 查询中,我得到了一个 json 对象列表,我可以很容易地将其转换为我想要的表。 问题是查询编辑器只允许我选择一个又一个结果,而不能解析列表中的所有内容。
查询是:
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")
关于excel - Powerquery 迭代步骤列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37252100/