Power Query List.Generate 迭代错误

huangapple go评论54阅读模式
英文:

Power Query List.Generate iteration bug

问题

我在Power Query工作流程中使用以下的List.Generate函数,但未获得所需的结果:

outcome_list = List.Generate (
    () => [page = 1, result = fnGetFindings(1,outcome_id)],
    each not List.IsEmpty([result]),
    each [page= [page] + 1, result = fnGetFindings([page],outcome_id)],
    each [result]
)

函数fnGetFindings使用两个参数。第一个是页面号码。当我手动调用第2页时,它返回空,但我的结果却重复了第1页,默认情况下是第一次迭代。因此,我从第1页得到了两个结果列表,但应该只有一个列表。

如何修复这个M代码,以仅返回第1页一次?

英文:

I am using the following List.Generate function in a Power Query workflow, but not getting the desired results:

outcome_list = List.Generate (
    () => [page = 1, result = fnGetFindings(1,outcome_id)],
    each not List.IsEmpty([result]),
    each [page= [page] + 1, result = fnGetFindings([page],outcome_id)],
    each [result]
)

The function fnGetFindings uses two parameters. The first being the page number. When I invoke page 2 manually it returns empty, but my result is duplicating page 1 which is the first iteration by default. I am therefore getting two lists of results back from page 1, but it should only be one list.

How can I fix this M code to only return page 1 once?

答案1

得分: 1

() => [page = 2, result = fnGetFindings(1, outcome_id)]

英文:

Short answer, use

() => [page = 2, result = fnGetFindings(1,outcome_id)],

huangapple
  • 本文由 发表于 2023年6月19日 13:22:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76503801.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定