使用JSON进行Power Query中基于游标的分页

时间:2018-06-20 14:50:12

标签: jquery json excel pagination powerquery

我正在尝试在Microsft PowerBI中创建一个报告以显示附近区域的停车场,到目前为止,我只能设法获得前20个结果。

enter image description here

我尝试了以下递归,遍历每个页面,即使此方法在Facebook API上有效,也不适用于Google Maps API。

let
 iterations = 10,          // Number of iterations

 url = 
  "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=54.77614759999999,-1.5605721&radius=10000&type=parking&key=PleaseInsertYourAccesTokenHere",
 
 FnGetOnePage =
  (url) as record =>
   let
    Source = Json.Document(Web.Contents(url)),
    results = try Source[results] otherwise null,
    next_page_token = try Source[paging][next_page_token] otherwise null,
    res = [Data=results, Next=next_page_token]
   in
    res,

  GeneratedList =
  List.Generate(
   ()=>[i=0, res = FnGetOnePage(url)],
  each [i]<iterations and [res][Data]<>null,
   each [i=[i]+1, 
   res = FnGetOnePage([res][Next])],

   each [res][Data]),
    #"Converted to Table" = Table.FromList(GeneratedList, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    #"Converted to Table"

如果有人可以指出正确的方向,我将不胜感激?解决此问题的正确方法是什么?非常感谢。

0 个答案:

没有答案