Power Query - 对不同参数值的多个请求

Power Query - Multiple request for different parameter values

我是使用 Power Query for REST 的新手 API 并且有一个 Power BI 报告需要修改以引入额外的数据。我已经为 return 数据开发了一个查询和自定义函数,它适用于单个 STATUS 请求参数值。这是在下面的语句中;

Source = Json.Document(Web.Contents("https://api.clockify.me/api/v1" & "/workspaces/"& Workspace&"/approval-requests?page="&Page&"&page-size="&PageSize&"&status="&Status,
                          [Headers=[#"X-API-Key"=#"X-API-Key",
                                     #"Content-Type"="JSON"]]
                                     )
                                     ),

不过,我需要 return 查询中所有四个状态代码(已批准、待定、已拒绝、APPROVAL_WITHDRAWN")的值。 Clockify 建议此 API 不支持多个参数值,我需要分别为每个状态提取请求。不幸的是,我不知道如何重组我的查询来做到这一点,所以非常感谢任何建议。

谢谢

下面显示了完整的查询和自定义函数;

let
    Source = "",
    Custom1 = List.Numbers(1 as number, 50 as number) as list,
    #"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type text}}),
    #"Invoked Custom Function" = Table.AddColumn(#"Changed Type", "Data", each get_page_fx([Column1])),
    #"Removed Errors" = Table.RemoveRowsWithErrors(#"Invoked Custom Function", {"Column1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Removed Errors",{"Column1"}),
    #"Removed Errors1" = Table.RemoveRowsWithErrors(#"Removed Columns", {"Data"}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Removed Errors1", "Data", {"id", "workspaceId", "dateRange.start", "dateRange.end", "owner.userId", "owner.userName", "owner.timezone", "owner.startOfWeek", "status.state", "status.updatedBy", "status.updatedByUserName", "status.updatedAt", "status.note"}, {"Data.id", "Data.workspaceId", "Data.dateRange.start", "Data.dateRange.end", "Data.owner.userId", "Data.owner.userName", "Data.owner.timezone", "Data.owner.startOfWeek", "Data.status.state", "Data.status.updatedBy", "Data.status.updatedByUserName", "Data.status.updatedAt", "Data.status.note"})
in
    #"Expanded Data

(Page as text) =>

let
  
     Source = Json.Document(
            Web.Contents("https://api.clockify.me/api/v1" & "/workspaces/"& Workspace&"/approval-requests?page="&Page&"&page-size="&PageSize&"&status="&Status,
                  [Headers=[#"X-API-Key"=#"X-API-Key",
                             #"Content-Type"="JSON"]]
                             )
                             ),
 
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "workspaceId", "dateRange", "owner", "status"}, {"id", "workspaceId", "dateRange", "owner", "status"}),
    #"Expanded dateRange" = Table.ExpandRecordColumn(#"Expanded Column1", "dateRange", {"start", "end"}, {"dateRange.start", "dateRange.end"}),
    #"Expanded owner" = Table.ExpandRecordColumn(#"Expanded dateRange", "owner", {"userId", "userName", "timezone", "startOfWeek"}, {"owner.userId", "owner.userName", "owner.timezone", "owner.startOfWeek"}),
    #"Expanded status" = Table.ExpandRecordColumn(#"Expanded owner", "status", {"state", "updatedBy", "updatedByUserName", "updatedAt", "note"}, {"status.state", "status.updatedBy", "status.updatedByUserName", "status.updatedAt", "status.note"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded status",{{"id", type text}, {"workspaceId", type text}, {"dateRange.start", type datetime}, {"dateRange.end", type datetime}, {"owner.userId", type text}, {"owner.userName", type text}, {"owner.timezone", type text}, {"owner.startOfWeek", type text}, {"status.state", type text}, {"status.updatedBy", type text}, {"status.updatedByUserName", type text}, {"status.updatedAt", type datetime}, {"status.note", type any}})
in
    #"Changed Type"

将状态硬编码到函数中。将该函数复制 3 次以上,每次使用不同的状态和不同的查询名称。在主查询中,您为 get_page_fx([Column1])) 添加一列。再添加三列,一列一列,每列调用三个新函数之一:get_page_fx2([Column1])) get_page_fx3([Column1])) 和 get_page_fx4( [第 1 列]))。这就是所有数据。如果需要,您可以将列与 append

组合起来