All eazyBI for Jira eazyBI for Confluence Private eazyBI

Days in Priority (TEMPLATE)

Calculated field to analyze how many days the issue was in each priority until the issue resolution date, you can precalculate the time between priority changes based on issue change history for each issue and then import this information as a measure Days in priority. The measure is also associated with the Time dimension (by transition from the priority change date).

Account specific calculated field

Account calculated fields (RENAMED) are defined in Source Data → Import options.

Settings for the new field

Internal name

prioritydays

Display nameDays in priority
Data type

decimal 

Measure

check the box

Additional advanced settings
multiple_dimensions = ["Time","Priority"]

Custom JavaScript code:

var priorityhistory = new Array();
var datefrom = issue.fields.created;
var priority = null;
resolution = false;
issue.changelog.histories.forEach(function(history){
  history.items.forEach(function(historyItem){
  if (historyItem.field == "priority") {
    priority = historyItem.fromString;
    if (! resolution) {
      dateto = history.created;
      if(priority){
        duration = (Date.parse(dateto) - Date.parse(datefrom)) / 1000 / 60 / 60 / 24;
        priorityhistory.push(dateto.toString().substr(0,10) + "," + priority + "," + duration);
      }
      datefrom = dateto;
      priority = historyItem.toString;
    }
  }
  if (historyItem.field == "resolution") {
    if (historyItem.to) resolution = true;
    else resolution = false;
  }
  });
});
// resolved issues without assignee change
issue.fields.customfield_prioritydays = priorityhistory.join("\n");

Global calculated field

Global calculated fields (RENAMED) are defined in eazyBI advanced settings.

Here are the settings for the new field definitions. You should insert the JavaScript (the code given above) below the line // Insert here the Custom JavaScript codeKeep the opening and closing quotation marks. ''', do not delete them.

[jira.customfield_prioritydays]
name = "Days in priority"
data_type = "decimal"
measure = true
multiple_dimensions = ["Time","Priority"]
javascript_code = '''
  // Insert here the Custom JavaScript code
'''