I got this solution proposed by one of the community response and I tried the code to check the function response same as the JIRA API results in the total count.
Two issues I faced:
- As the number of response tickets is higher it takes a long time for the query to return, and not work asynchronously.
- The second issue is something if I can seek advice from experts here in Power Query. I cant refresh the paginated data outside the PowerBI desktop app, after I make it published and use the Dataset refresh and see the refresh history from the schedule screen. I am getting the following error.
This dataset includes a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service, this dataset won't be refreshed. Learn more: https://aka.ms/dynamic-data-sources.
In some research I found this about a solution mentioning for pagination but still, the problem with huge data remains that refresh gives the above error.
I read about some RelativeDocument and M functions but am not savvy for that understanding.
Here is my Power Query snippet which I request can be suggested to be modified with anything I am missing.
let
BaseUrl = "https://<base URL>/rest/api/2/search?jql=filter=22344",
JiraIDPerPage = 400,
GetJson = (Url) =>
let
RawData = Web.Contents(Url,([Headers=[Authorization="Bearer TOKEN"]])),
Json = Json.Document(RawData)
in Json,
GetJiraIDCount = () =>
let Url = BaseUrl & "&maxResults=0",
Json = GetJson(Url),
Count = Json[#"total"]
in Count,
GetPage = (Index) =>
let Skip = "&startAt=" & Text.From(Index * JiraIDPerPage),
Top = "&maxResults=" & Text.From(JiraIDPerPage),
Url = BaseUrl & Skip & Top,
Json = GetJson(Url),
Value = Json[#"issues"]
in Value,
JiraIDCount = List.Max({ JiraIDPerPage, GetJiraIDCount() }),
PageCount = Number.RoundUp(JiraIDCount / JiraIDPerPage),
PageIndices = { 0 .. PageCount - 1 },
Pages = List.Transform(PageIndices, each GetPage(_)),
JiraID = List.Union(Pages),
Table = Table.FromList(JiraID, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(Table, "Column1", {"id", "key", "fields"}, {"Column1.id", "Column1.key", "Column1.fields"}),
#"Expanded Column1.fields1" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.fields", {"summary", "reporter", "assignee", "created", "status"}, {"Column1.fields.summary", "Column1.fields.reporter", "Column1.fields.assignee", "Column1.fields.created", "Column1.fields.status"}),
#"Expanded Column1.fields.assignee" = Table.ExpandRecordColumn(#"Expanded Column1.fields1", "Column1.fields.assignee", {"name"}, {"Column1.fields.assignee.name"}),
#"Expanded Column1.fields.reporter" = Table.ExpandRecordColumn(#"Expanded Column1.fields.assignee", "Column1.fields.reporter", {"displayName"}, {"Column1.fields.reporter.displayName"}),
#"Expanded Column1.fields.status" = Table.ExpandRecordColumn(#"Expanded Column1.fields.reporter", "Column1.fields.status", {"name"}, {"Column1.fields.status.name"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Column1.fields.status",{{"Column1.fields.created", type datetimezone}})
in
#"Changed Type"