Skip to content

Instantly share code, notes, and snippets.

@tdalon
Last active October 6, 2020 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdalon/ab63825bc1bd22d7dfa48177380b722d to your computer and use it in GitHub Desktop.
Save tdalon/ab63825bc1bd22d7dfa48177380b722d to your computer and use it in GitHub Desktop.
PowerBi / PowerQuery Jira Template
let
// Get total
Source = Json.Document(Web.Contents(JiraRootUrl&"/rest/api/2/search?jql=filter="&JiraFilterId&"&maxResults=1&fields=["&JiraFields&"]")),
total = Source[total],
GetChunk = (previousTable, maxResults as number) as table =>
let
startAt = if previousTable = null then 0 else Table.RowCount(previousTable) + 1,
maxRes = if (maxRows - startAt < maxResults) then maxRows - startAt else maxResults,
MergedTable = if (startAt > total) or ((maxRows>0) and (startAt > maxRows)) then previousTable else
let
Chunk = Json.Document(Web.Contents(JiraRootUrl&"/rest/api/2/search?jql=filter="&JiraFilterId&"&fields=["&JiraFields&"]&maxResults="&Text.From(maxRes)&"&startAt="&Text.From(startAt))),
ChunkTable = Table.FromList(Chunk[issues], Splitter.SplitByNothing(), {"Column1"}),
table1 = if previousTable = null then ChunkTable else Table.Combine({previousTable,ChunkTable}),
table2 = @GetChunk(table1, maxResults) // recursive call
in
table2
in MergedTable,
IssuesTable = GetChunk(null,maxResults)
in
IssuesTable
@tdalon
Copy link
Author

tdalon commented Oct 6, 2020

Explanation and PBI template can be found here https://tdalon.blogspot.com/jira2powerbi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment