简体   繁体   English

API,Power BI上的“条件逻辑-循环参数”页面

[英]Conditional Logic - Looping Parameter page on API, Power BI

So the problem is: I wanna increment the parameter page (++1), until the last page. 所以问题是:我想增加参数页(++ 1),直到最后一页。 In the future get the data on the page and go to the next page. 以后在页面上获取数据并转到下一页。

EX: 例如:

https://api.github.com/repos/ " & login & "/" & repository & "/issues?state=all&sort=created&page=" & Text.From( page ) // page is my variable https://api.github.com/repos/“&登录&” /“&存储库&” / issues?state = all&sort = created&page =“&Text.From( page )//页面是我的变量

Thinking as JAVA man we just adding a variable and use for/while depending the situation. 作为JAVA的人,我们只是添加一个变量并根据情况使用/。

Now, how to do that using M language ? 现在,如何使用M语言来做到这一点?

I did the homework and this sites have some information: 我做了作业,这个站点有一些信息:

toadworld.com/platforms/sql-server/b/weblog/archive/2014/03/10/conditional-logic-in-power-query toadworld.com/platforms/sql-server/b/weblog/archive/2014/03/10/conditional-logic-in-power-query

https://seddryck.wordpress.com/2017/01/07/do-while-loop-with-power-bi-m-language/ https://seddryck.wordpress.com/2017/01/07/do-while-loop-with-power-bi-m-language/

But it's not working. 但这不起作用。 :( :(

Anyone can help me? 有人可以帮助我吗?

I'm new in this M world. 我是这个M世界的新手。

Thanks. 谢谢。

You can repeat calling a function. 您可以重复调用一个函数。 Please note @Factorial. 请注意@Factorial。 The @ is needed to repeat the function. 需要@以重复该功能。 I assume you can change the code below to fit you needs. 我认为您可以更改下面的代码以适合您的需求。

(Connector as text, Take as number) as list =>
let
    _token = Binary.ToText(Text.ToBinary("" & Token & ""), BinaryEncoding.Base64),
    fGetData = (Skip as number) => Json.Document(Web.Contents("" & URL & Connector &"?skip=" & Number.ToText(Skip) & "&take=" & Number.ToText(Take) & "", [Headers=[Authorization="Bearer " & _token & ""]])),
    Factorial = (res, skip) =>
    if List.Count(res) < Take then res else Combine(res, skip + Take),
    Combine = (x, skip) => List.Combine({ x, @Factorial(fGetData(skip)[rows], skip) }),
    Result = Factorial(fGetData(0)[rows], 0)
in
Result

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM