Help - Need calulated measure(s) for Counting changes in Issue "Types"

Hi @erichard00,

Out of the box, there is no such measure to get time spent in each issue type. You may try to build custom calculation and count the time between two dates based on measures Transition to first timestamp and Transition from last timestamp, but this won’t be accurate if an issue can get the same issue type twice and might be a quite heavy calculation.

I would recommend import new measure using JavaScript calculated custom fields. You may use the code for “Days for Assignee” as an example to build measure for “Days for Issue Type”.

  1. Go to eazyBI Advanced Settings and paste in the custom measure definition with JavaScript. Note that those settings are available only to Jira system administrators and eazyBI admins.
    The code for the custom measure with JavaScript might look like this:
[jira.customfield_days_for_issuetype]
name = "Days for Issue Type"
data_type = "decimal"
measure = true
multiple_dimensions = ["Time","Issue Type"]
javascript_code = '''
var issuetypehistory = new Array();
var datefrom = issue.fields.created;
var issuetype = null;
resolution = false;

issue.changelog.histories.forEach(function(history){
 history.items.forEach(function(historyItem){
  if (historyItem.field == "issuetype" && ! resolution) {
   issuetype = historyItem.fromString;
   dateto = history.created;
   if(issuetype){
     duration = (Date.parse(dateto) - Date.parse(datefrom)) / 1000 / 60 / 60 / 24;
     issuetypehistory.push(dateto.toString().substr(0,10) + "," + issuetype + "," + duration); 
   }
   datefrom = dateto;
   issuetype = historyItem.to;
 }
 if (historyItem.field == "resolution") {
   if (historyItem.to) resolution = true;
   else resolution = false; 
 }
 });
});

if (issue.fields.resolutiondate && (issue.fields.issuetype || issuetype)) {
 if (!issuetype) issuetype = issue.fields.issuetype.name;
 duration = (Date.parse(issue.fields.resolutiondate) - Date.parse(datefrom)) / 1000 / 60 / 60 / 24;
 issuetypehistory.push(issue.fields.resolutiondate.toString().substr(0,10) + "," + issuetype + "," + duration); 
 }

issue.fields.customfield_days_for_issuetype = issuetypehistory.join("\n");
'''
  1. Then go to import options and select custom field “Days for Issue Type” for data import as measure and as property.

  2. After data import, a new measure Days for Issue Type (Measures -> Select member -> Custom field) will be available for your reports. Use it with Issue Type dimension in the report.

Best,
Zane / support@eazyBI.com

1 Like