Calculating Blocked time on Issues using Flagged Field

JIRA Software has a Flagged field used on Kanban or Scrum board for making a visual indication of blocked work. I have started importing Flagged as a dimension and also import the Flagged change history.

How would I form a Measure that calculated the amount of time an issue was in the flagged status so that I can sum the total amount of time items are blocked?

How would I do a similar calculation so that I can calculate the amount of blocked time by status?

1 Like

Guy,

You need to create a new custom calculated field using the Javascript for the solution.

These advanced settings create a new measure giving the number of days for the Impediment status for the completed cycles (when the Impediment flag was also removed from the issue):

[jira.customfield_days_flagged]
name = "Days Flagged Impediment"
data_type="decimal"
measure = true
javascript_code='''

var datefrom = Date.parse(issue.fields.created);
var days_flagged = 0.0;
issue.changelog.histories.forEach(function(history){
    history.items.forEach(function(historyItem){
      if (historyItem.field == "Flagged") {
        to = historyItem.toString;
        from = historyItem.fromString;
        if(to.equals("Impediment")) {
          date_from = Date.parse(history.created);
        }
        if (from && from.equals("Impediment")) {
          date_to = Date.parse(history.created);
          days_flagged += (date_to - date_from) / 1000/ 60 /60 / 24 ;
        }
      }
    });
  });
if (days_flagged>0) issue.fields.customfield_days_flagged=days_flagged;
'''

Kindly,
Janis, eazyBI support

@janis.plume i tried this but im not seeing the measure. do i need to do anything after i edit the advance settings?

You need to select this field from the data import options and run a new data import:


After the import, a new measure should be available in the data cube.

Kindly,
Janis, eazyBI support

I got it to go but i am not seeing any data. Any thoughts @janis.plume ?

Hi,

One possible reason is that there might be needed a full data re-import for that. Please, check if that might help.

As you seem to be using the “Flagged” dimension note that those issues which are in status “Impediment” might have no data. The calculation detects those issues having left this status. Please, try the report showing also the (none) member for the debugging:

Please, contact eazyBI support once you need further debugging of this solution.

Kindly,