英文:
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)],
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论