Calculating total time when an issue is Flagged in Working Days

Hello,

I have a need to get the total time an issue was flagged via the Flagged field in Working Days.

There is this article regarding Calculating Blocked time on Issues using Flagged Field that uses JavaScript through Advance Settings, but it gives a value is total days (including weekends and holidays).

Here is the JavaScript from the article:

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

var date_from = 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;
'''

How would I alter the query to give the value in Working Days?

Thank You in advance,
Larry R.

Hi larryrtn,
Welcome to the eazyBI community!

If you have imported the Issue change history and selected to import the field “Flagged” with import value changes option, you could use the following formula, to get, for example, Workdays flagged as Impediment:

([Measures].[Workdays in transition],
[Flagged].[Impediment])

This measure will take into account all non-working days defined in Time dimension import options.

I hope this helps.

Best,
Ilze