Calculate the count of transitions for Exposure field

Hi,

Exposure field contains the values:
1-Critical
2-High
3-Medium
4-Low

Bug can have transitions between any of these values.

How can we calculate the number of times any bug goes through transitions between any of these values, over time?

Thanks,
Vrukesh

eazyBI allows importing and analyzing changes in single value custom fields. You would like to enable the option import changes for the custom field, though.

However, the default measures will show you only how many issues were moved to/from a particular custom field value over time. You can define a custom measure to track the changes for a custom field:

([Measures].[Transitions to],
 [Transition Field].[<custom field name>])

The measure above will count values set at the issue creation as well.

It might be a bit tricky and complex if you would like to count changes between two different values. For example, a count of issues moved from High to Critical. While you can try using the MDX formula for this (compare the timestamp of a status move from High with a timestamp of a status move to Critical), it might get even messier if an issue changes values in this field several times.

Therefore, it would be more reliable and relevant to define a new dimension and measure with calculated JavaScript code to represent particular changes and count those changes.

Here is an example calculation for default field Priority for this case. You would like to replace priority with your custom field Name (case sensitive)

#define dimension to represent transctions changes in custom field
[jira.customfield_pri_changes]
name = "Priority changes" # the the dimension name and address it in parameter multiple_dimensions in the definition below
data_type = "string"
dimension = true
separate_table = true

#define measure tocount those changes
[jira.customfield_pri_changed]
name = "Priority changed"
data_type = "integer"
measure = true
multiple_dimensions = ["Priority changes","Time"] # set the dimension name from the definiiotn above
javascript_code = '''
var priorityChanges = [];
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
  var histories = issue.changelog.histories;
  for (var i = 0; i < histories.length; i++) {
  var history = histories[i];
  if (history.items && history.items.length > 0) {
  for (var n = 0; n < history.items.length; n++) {
    var item = history.items[n];
    if (item.field == 'priority' && item.toString != item.fromString  ){ // define a custom field name - case sensitive instead of 'priority'
    	toValue = item.toString ? item.toString : "(none)";
    	fromValue = item.fromString ? item.fromString : "(none)";
// add change in this pattern: fromValue => toValue,changeDate,1
priorityChanges.push(fromValue + " => " + toValue + "," + history.created.toString().substr(0,10) + ",1");
    }
  }
  }
  }
// add all changes as a result with a new line divider 
  issue.fields.customfield_pri_changed = priorityChanges.join("\n");
}
'''

I would suggest renaming the variable names to reflect the customfield so that it would be easier to understand what the code does.

  1. Test javaScript code:
    Open import options for edit and apply the JavaScript to Custom JavaScript code. Test the code with several issues. Please check how to test the javascript code.
    Remove the code from this field after testing.

  2. Add custom field definitions to eazyBI advanced settings.
    You might need help from a Jira administrator or eazyBI administrator to do this for you. eazyBI advanced settings are common for all accounts, and only Jira/eazyBI administrators have access to the settings.

  3. Select custom fields for import.
    Open source data Jira import options for edit after changes in advanced settings and select both custom fields for import and run an import. Import will create a new dimension and measure.

You would like to use a new dimension in combination with this new measure for your reports:

Daina / support@eazybi.com

Hi Daina,

Thanks a lot for the detailed reply! Really appreciate it very much!

We will try it out, and get back in case we have any more queries.

Regards,
Vrukesh

Hi @vrukesh ,

I have tried to use the JavaScript code provided by @daina.tupule but I can’t get any result. And when I test with a specific issue I get this string error (although reviewing the code I don’t see anything missing for strings values). Did you finally manage to use it? Or did you get the same error.

Thank you very much in advance

The definitions I shared should be added to eazyBI advanced settings. They are accessible via top right corner > gear icon > settings. Please note those settings are available for Jira admins only. They are common for all acounts.

You can test the javascript part of the code in import options Custom JavaScript code. However, you can use javascript only there. Copy a formula from a parameter javascript_code between (not including) opening and closing apostrophes (’’’). See more here on how to test the javascript part of the code.

Daina / support@eazybi.com

Hi @daina.tupule

Thank you very much for your reply. The truth is that I followed all the steps correctly and added the definitions to eazyBI advanced settings but the report still does not show me the table with the priority changes counts (I have changed many priority issues but it doesn’t seem to be picking them up)

Regards,
Javi

Hi again @daina.tupule ,

And also you were right with the code testing. When I tested with just the code in JS no error appeared and I could see how the “customfield_pri_changed” field appeared correctly. That’s why I’m surprised it’s not reflected in the report.

I would be very grateful if you could help me figure out what is going on.

Regards,
Javi

Here are some steps you can make for debugging this.

You can test import for new custom fields in Custom javaScript code after adding it to eazyBI advanced settings. Do not use any javascript. Test it with some issues. eazyBI will get the code from advanced settings.

When you are not using any javascript in import options custom JavaScript code, eazyBI will show results for imported fields anyway.

Typo errors are quite common.
Make sure you assigned the value to the field you defined.
Custom field ID (customfield_pri_changed) from the definition:

[jira.customfield_pri_changed]

Should match the field name customfield_pri_changed you assigned the values:

issue.fields.customfield_pri_changed = priorityChanges.join("\n");

The pattern used in definitions is important as well. For example, I typically like to copy the field’s ID into the results field to make sure it is correct.

If you have any changes in the definitions, please run full data re-import to make it work. eazyBI runs incremental imports by default and might not recognize changes in eazyBI advanced settings.

Test import results in eazyBI report.
The current field is quite complex. This is because you imported two new fields filling in values with one script. It is more complex for testing in this case.
I would suggest checking the values in property Issue Priority changed. It should match the results in JavaScript.

The last step you can make, if nothing above helps, is reset the field import for those two fields.
Please use double full imports for this:

  1. Remove both fields from import options (any selection) run an import. This will delete any previous setup for those fields.
  2. Select back both fields for import. Run an import. This will create new data structures in eazyBI.

If even this does not help, don’t hesitate to get in touch with us via support@eazybi.com.

Daina / support@eazybi.com

Hello @daina.tupule ,

It seems that the full data re-import has worked. I can see all the data in the table. Thank you very much for your help. I am very grateful to you :slight_smile:

Kindly,
Javier