We are happy to see our customers use the suggestions from this post to import ID’s of any previous sprint.
There is a more general JavaScript custom field example All Sprint ID. The custom field could be imported as property and will show you any sprint, including the current for any issue. You can use it in many custom calculations as well.
The custom field will include any sprint from the issue itself as well. You would like to update the code using Sprint custom field ID instead of NNNNN in the code below (2 places):
JavaScript custom field example for Server/DC
[jira.customfield_allsprints]
name = "All Sprint ID"
data_type = "text"
json_fields = ["customfield_NNNNN"]
javascript_code = '''
sprintsHistory = new Array();
firstSprint = true;
issue.changelog.histories.forEach(function(history){
history.items.forEach(function(historyItem){
if (historyItem.field == "Sprint") {
if (firstSprint) {
sprintsFrom = historyItem.from;
if(sprintsFrom){
sprintsHistory = sprintsHistory.concat(sprintsFrom.replace(/ /g, "").split(","));
}
firstSprint = false;
}
sprintsTo = historyItem.to;
if(sprintsTo){
sprintsHistory = sprintsHistory.concat(sprintsTo.replace(/ /g, "").split(","));
}
}
});
});
//add all sprints from Sprint custom field as well:
var sprintset = issue.fields.customfield_NNNNN;
if (sprintset) {
sprintset.forEach(function(sprintlong){
var sprintidset = sprintlong.match("id=(\\d+)")
if (sprintidset && sprintidset[1]) sprintsHistory.push(sprintidset[1]);
});
}
issue.fields.customfield_allsprints = _.uniq(sprintsHistory).join(",");
'''
JavaScript custom field example for Cloud
[jira.customfield_allsprints]
name = "All Sprint ID"
data_type = "text"
json_fields = ["customfield_NNNNN"]
javascript_code = '''
sprintsHistory = new Array();
firstSprint = true;
issue.changelog.histories.forEach(function(history){
history.items.forEach(function(historyItem){
if (historyItem.field == "Sprint") {
if (firstSprint) {
sprintsFrom = historyItem.from;
if(sprintsFrom){
sprintsHistory = sprintsHistory.concat(sprintsFrom.replace(/ /g, "").split(","));
}
firstSprint = false;
}
sprintsTo = historyItem.to;
if(sprintsTo){
sprintsHistory = sprintsHistory.concat(sprintsTo.replace(/ /g, "").split(","));
}
}
});
});
//add all sprints from Sprint custom field as well. The change is in this part
var sprintset = issue.fields.customfield_NNNNN;
if (sprintset) {
sprintset.forEach(function(sprintlong){
sprintsHistory.push(String(sprintlong.id));
});
}
issue.fields.customfield_allsprints = _.uniq(sprintsHistory).join(",");
'''
Add the custom field to eazyBI advanced settings and then select it for import in any account where you would like to define more complex scenarios on sprint data analysis.
Here is an example formula using this code to count issues moved to this sprint from the previous sprint:
CASE WHEN
[Sprint].Currentmember.Level.name = "Sprint"
THEN
NonZero(SUM(
Filter(
Descendants([Issue].Currentmember, [Issue].[Issue]),
-- filter by properties
-- issue is (was) in Sprint
Cast([Sprint].CurrentMember.Key as String) MATCHES
Replace(CoalesceEmpty([Measures].[Issue All Sprint ID], ""),",","|")
AND
-- issue was in previous Sprint as well
Cast([Sprint].CurrentMember.PrevMember.Key as String) MATCHES
Replace(CoalesceEmpty([Measures].[Issue All Sprint ID], ""),",","|")
),
-- counter and a filter by report context
[Measures].[Transitions to issues count]
))
END
This measure will show an issue for any sprint it was moved over, even it was moved to the next sprint several times.
Daina / support@eazybi.com