# Aggregate Sprint By Name

**URL:** <https://community.eazybi.com/t/aggregate-sprint-by-name/6591>\
**Category:** Questions & Answers\
**Tags:** dataimport, hierarchy, sprint\
**Created:** [April 12, 2021, 5:20pm UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591 "2021-04-12T17:20:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gisela\_Nogueira](https://community.eazybi.com/user_avatar/community.eazybi.com/gisela_nogueira/32/4679_2.png) [@Gisela\_Nogueira](https://community.eazybi.com/u/Gisela_Nogueira)\
**Post date:** [April 12, 2021, 5:20pm UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/1 "2021-04-12T17:20:46Z")

</div>

Hi, Is there a way to create this aggregation automatically, instead of create member my member? I want to aggregate all the sprints with the same start date.

---

<div class="post-metadata">

**Author:** ![zane.baranovska](https://community.eazybi.com/user_avatar/community.eazybi.com/zane.baranovska/32/7209_2.png) [@zane.baranovska](https://community.eazybi.com/u/zane.baranovska)\
**Post date:** [April 29, 2021, 7:36am UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/2 "2021-04-29T07:36:24Z")

</div>

Hi @Gisela_Nogueira,

You can **add custom hierarchy** that would **group sprints** by matching string or numeric properties (sprints with the same property value are grouped) in Sprint dimension.

1. First, you might want to import criteria for grouping sprints as a property using **additional data import** : [Additional data import into Jira Issues cube](https://docs.eazybi.com/eazybijira/data-import/jira-issues-import/additional-data-import-into-jira-issues-cube).  
For example, import planned start period as string, program increment, or some other attribute indicates which sprints should be grouped.

2. Then, in Sprint dimension, chose to **add a custom hierarchy** : [Create reports](https://docs.eazybi.com/eazybijira/analyze-and-visualize/create-reports#Createreports-AddcustomhierarchiestospecificJira,Confluence,andInsightdimensions).

And here is a training video on additional data import and how to build a custom hierarchy from those data:  
[![Screenshot 2021-05-10 at 17.06.36](https://community.eazybi.com/uploads/default/original/2X/b/b730d90121834c4a03b004632385b54b268d96ea.jpeg)](https://eazybi.wistia.com/medias/zqcldknsnp)  
Presentation slides: [Power-up-reports-with-additional-data-import.pdf](https://community.eazybi.com/uploads/short-url/46R5zz3wAQOvlujRPapLo0XMfMO.pdf) (5.9 MB)

Please see this community post on a similar use case and solution how to import Sprint properties from REST API:

> [@Combining different teams sprints into one](https://community.eazybi.com/t/combining-different-teams-sprints-into-one/4120/3):
>
> With version 6.1 we added a new to create custom hierarchies in some dimensions, including Sprints. You would like to import custom properties for sprints to represent a potential grouping mechanism. For example, you can import a property cycle for Sprints with [additional data import](https://docs.eazybi.com/eazybijira/data-import/jira-issues-import/additional-data-import-into-jira-issues-cube). Then you can use this custom property Cycle to build a [new custom hierarchy](https://docs.eazybi.com/eazybi/analyze-and-visualize/create-reports#Createreports-AddcustomhierarchiestospecificJiraandConfluencedimensions) in Sprint dimension and group sprints by cycles dynamically. Import additional property to Sprint based on Sprint naming pattern XX Spr…

Best,  
Zane / [support@eazyBI.com](mailto:support@eazyBI.com)

---

<div class="post-metadata">

**Author:** ![zane.baranovska](https://community.eazybi.com/user_avatar/community.eazybi.com/zane.baranovska/32/7209_2.png) [@zane.baranovska](https://community.eazybi.com/u/zane.baranovska)\
**Post date:** [May 11, 2021, 12:56pm UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/3 "2021-05-11T12:56:42Z")

</div>

Here is an example of REST API that would import **Week cycle** as **Sprint property**.  
This Sprint property will pick the Sprint start date and show it to the Monday of that week, and import the property with this pattern: %yW%U, %b %d %Y, for example, **20W39, Sep 28 2020** - year, week number, and week start date)

To use this code:

1. In Source Data (where you already have Jira as a data source), select **“Add new source application”**.

2. Chose the option to **“import definition”** and paste in the code below:

> **Import definition for new data source**
>
> ```auto
> {
> "application_type": "rest_api",
> "application_params": {
> "source_params": {
> "url": "http://jira811.internal:8810/rest/agile/1.0/board?type=scrum",
> "pagination": "offset_limit",
> "incremental": null,
> "incremental_stop_import": null,
> "authentication_type": "basic",
> "username": "admin",
> "content_type": "json",
> "custom_javascript_code": "\n\n// retrieves all sprints within one board and will go from the last sprint and rank decreasingly closed sprints\nvar sprints = [{\n sprint_id: null,\n sprint_week: null \n}];\nvar allSprints = [];\nvar allSprintsLoaded = false;\nstartAt = 0;\nmaxResult = 50;\nif (doc.type == \"scrum\") {\n\n do \n {\n result = getDocument( \"/rest/agile/1.0/board/\" + doc.id + \"/sprint?startAt=\" + startAt + \"&maxResults=\" + maxResult, {ignoreErrors: \"404\"});\n if (result && result.values ) {\n allSprints = allSprints.concat(result.values);\n allSprintsLoaded = result.isLast;\n startAt = startAt + maxResult;\n }\n }\n while (!allSprintsLoaded); \n \n if (allSprints ) { \n for(var i = 0; i < allSprints.length; i++) {\n var sprint = allSprints[i];\n if (sprint && sprint.originBoardId == doc.id ) {\n \n if (sprint.startDate) {\n date = new Date(Date.parse(sprint.startDate));\n date.setUTCDate(date.getUTCDate() + 1 - (date.getUTCDay()||7));\n sprints.push({\n sprint_id: sprint.id,\n sprint_week: strftime(\"%yW%U, %b %d %Y\", date)\n });\n }\n }\n }\n} \n\n}\nreturn _.uniq(sprints);",
> "json_data_path": "$.values",
> "offset_parameter": "startAt",
> "limit_parameter": "maxResults",
> "limit_value": 50
> },
> "extra_options": {
> "regular_import_frequency": null,
> "regular_import_at": "",
> "time_zone": "Helsinki"
> }
> },
> "source_cube_name": "Issues",
> "columns": [
> {
> "name": "sprint_id",
> "data_type": "integer",
> "dimension": "Sprint",
> "dimension_level": "Sprint",
> "key_column": true,
> "skip_missing": true
> },
> {
> "name": "sprint_week",
> "data_type": "string",
> "dimension": "Sprint",
> "dimension_level": "Sprint",
> "property": "Week cycle"
> }
> ]
> }
> 
> ```

1. **Adjust** the **REST API source parameters** (URL, authentification) to match your Jira instance ([Import from REST API](https://docs.eazybi.com/eazybi/data-import/import-from-rest-api#ImportfromRESTAPI-RESTAPIsourceparameters))

2. Import data.

3. In the report, Sprint dimension, choose to **add custom hierarchy** and select property “Weekly cycle” ([Create reports](https://docs.eazybi.com/eazybijira/analyze-and-visualize/create-reports#Createreports-AddcustomhierarchiestospecificJira,Confluence,andInsightdimensions)).

Here are several reports in **eazyBI Demo Training** account created based on this custom hierarchy:  
[**Sprints by weeks balance**](https://eazybi.com/accounts/22010/cubes/Issues/reports/725641-sprints-by-weeks-balance)  
[**Sprints by weeks velocity**](https://eazybi.com/accounts/22010/cubes/Issues/reports/787607-sprints-by-weeks-velocity)  
[**Sprints by weeks current cycle story points burn-down**](https://eazybi.com/accounts/22010/cubes/Issues/reports/787624-sprints-by-weeks-current-cycle-story-points-burn-down)

Best,  
Zane / [support@eazyBI.com](mailto:support@eazyBI.com)

---

<div class="post-metadata">

**Author:** ![Gisela\_Nogueira](https://community.eazybi.com/user_avatar/community.eazybi.com/gisela_nogueira/32/4679_2.png) [@Gisela\_Nogueira](https://community.eazybi.com/u/Gisela_Nogueira)\
**Post date:** [June 14, 2021, 8:54pm UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/4 "2021-06-14T20:54:24Z")

</div>

Hi, @zane.baranovska,

The code show an error when I import, I think the javascript is not complete, can you post the code?

---

<div class="post-metadata">

**Author:** ![zane.baranovska](https://community.eazybi.com/user_avatar/community.eazybi.com/zane.baranovska/32/7209_2.png) [@zane.baranovska](https://community.eazybi.com/u/zane.baranovska)\
**Post date:** [June 15, 2021, 6:40am UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/5 "2021-06-15T06:40:18Z")

</div>

@Gisela_Nogueira, the given import definition for the new data source already contains the JavaScript code to format the values and some parameters for the REST API. I just tested the import definition and the JavaScript, works as expected.

Where you have placed the “import definition”? And what error do you get?

---

<div class="post-metadata">

**Author:** ![Gisela\_Nogueira](https://community.eazybi.com/user_avatar/community.eazybi.com/gisela_nogueira/32/4679_2.png) [@Gisela\_Nogueira](https://community.eazybi.com/u/Gisela_Nogueira)\
**Post date:** [June 15, 2021, 11:46am UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/6 "2021-06-15T11:46:57Z")

</div>

Hi, @zane.baranovska after changing the informations of my instance, show this error when I click in Continue:

 ![image](https://community.eazybi.com/uploads/default/original/2X/a/a5d9ab8b7163493ae5c19374f982e93c0c84147b.png)

---

<div class="post-metadata">

**Author:** ![zane.baranovska](https://community.eazybi.com/user_avatar/community.eazybi.com/zane.baranovska/32/7209_2.png) [@zane.baranovska](https://community.eazybi.com/u/zane.baranovska)\
**Post date:** [June 15, 2021, 3:51pm UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/7 "2021-06-15T15:51:13Z")

</div>

Thanks @Gisela_Nogueira!

It looks like the Community formatter changed a couple of JavaScript fields to URL links. I update the post and fixed the code in the import definition.

And here is the JavaScript part separately that transforms retrieved data in needed format for data mapping:

```auto
// retrieves all sprints within one board and will go from the last sprint and rank decreasingly closed sprints
var sprints = [{
 sprint_id: null,
 spint_week: null 
}];
var allSprints = [];
var allSprintsLoaded = false;
startAt = 0;
maxResult = 50;
if (doc.type == "scrum") {

 do 
 {
 result = getDocument( "/rest/agile/1.0/board/" + doc.id + "/sprint?startAt=" + startAt + "&maxResults=" + maxResult, {ignoreErrors: "404"});
 if (result && result.values ) {
 allSprints = allSprints.concat(result.values);
 allSprintsLoaded = result.isLast;
 startAt = startAt + maxResult;
 }
 }
 while (!allSprintsLoaded); 
 
 if (allSprints ) { 
 for(var i = 0; i < allSprints.length; i++) {
 var sprint = allSprints[i];
 if (sprint && sprint.originBoardId == doc.id ) {
 
 if (sprint.startDate) {
 date = new Date(Date.parse(sprint.startDate));
 date.setUTCDate(date.getUTCDate() + 1 - (date.getUTCDay()||7));
 sprints.push({
 sprint_id: sprint.id,
 spint_week: strftime("%yW%U, %b %d %Y", date)
 });
 }
 }
 }
} 

}
return _.uniq(sprints);

```

---

<div class="post-metadata">

**Author:** ![Gisela\_Nogueira](https://community.eazybi.com/user_avatar/community.eazybi.com/gisela_nogueira/32/4679_2.png) [@Gisela\_Nogueira](https://community.eazybi.com/u/Gisela_Nogueira)\
**Post date:** [June 15, 2021, 7:16pm UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/8 "2021-06-15T19:16:24Z")

</div>

@zane.baranovska  
Hi, Thanks, now show the group but when I open the hieraquy don´t show all the sprints but the number in the hieraquy sum all the sprints.

Wrong:

 ![image](https://community.eazybi.com/uploads/default/original/2X/6/6109fa50dbfabafe83d2d3aedbb45439588d61dc.png)

---

<div class="post-metadata">

**Author:** ![daina.tupule](https://community.eazybi.com/user_avatar/community.eazybi.com/daina.tupule/32/8838_2.png) [@daina.tupule](https://community.eazybi.com/u/daina.tupule)\
**Post date:** [September 23, 2021, 6:59am UTC](https://community.eazybi.com/t/aggregate-sprint-by-name/6591/9 "2021-09-23T06:59:38Z")

</div>

Week cycle should group all the sprints imported with a parameter where the week has the same name. There could be some filtering in the report when you do not see specific members.

Could you check if there are no **filter rows** option hiding some rows? It seems some sprints do not show up in the report. You can also collapse and expand the Week to get back the members if there are some removed manually from the report.

If you have any problems getting the report work please send the report definition to [support@eazybi.com](mailto:support@eazybi.com)

Daina / [support@eazybi.com](mailto:support@eazybi.com)
