Last active
October 6, 2020 16:37
-
-
Save tdalon/ab63825bc1bd22d7dfa48177380b722d to your computer and use it in GitHub Desktop.
PowerBi / PowerQuery Jira Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanation and PBI template can be found here https://tdalon.blogspot.com/jira2powerbi