Question: Counting the Number of Linked Issues

Hi All,
I have a quick question.

I set up a new Jira field in Advanced Settings based on a new linkage I had created. I’m able to import the data successfully and set it up for use as a dimension and a property.
When I set up a report, I can see the dimension for that linkage.

I tried setting up a report as follows:

  • Pages: Project, Time, Issue Type
  • Rows: Issue
  • Columns: Measures (issues created, plus another column for my linkage).

I get a table with each Jira ticket, a ‘1’ value in each row in the ‘Issues Created’ column, and a string for my linkage column.

Is there any way I can convert that string for the linkage column into another value, like an integer? I’d like to be able to sum/count these up and display the data week by week (i.e. how many of these linkages occur each week out of the overall total).

Thanks!

Hi, @jlayug!

There are several ways how to look at this:

First and most straightforward approach would be to count how many keys are in the Issue property. The following formula would do this by counting how many commas are in the string of bugs linked to the issue.

CASE WHEN NOT IsEmpty([Issue].CurrentMember.get('Bugs'))
THEN 
Len([Issue].CurrentMember.get('Bugs')) 
  - Len(Replace([Issue].CurrentMember.get('Bugs'), ',', '')) 
  + 1
END

Second way would be to count linked issues by getting them from the Issue dimension; see a similar request Need help with creating measure for imported linked issue key.
By getting the linked issues, you would have an option to group the linked issues by their creation date on the timeline. The formula would be similar to following

NonZero(Count(Filter(
  [Issue].[Issue].GetMembersByKeys(
    [Issue].CurrentMember.get('Bugs')),
  [Measures].[Issues created] > 0
)))

Lastly, eazyBI does not import the date when the link was added to the issue. If you are looking for such a count on the timeline, then you would need to create a script that runs through the issue changelog and finds the date when the link is added. In the Jira Server app, it would be possible to create a new scripted field to do this, in Jira Cloud it could be done with JavaScript calculated field.

Lauma / support@eazybi.com

1 Like

Hi Lauma,
Thank you very much! We’ll definitely try it out. :slight_smile:
J.P.

1 Like

Hi! I’m trying to use this solution but it doesn’t work. Almost all the solutions described in community use this [Bugs] dimension, but I don’t have this dimension and it doesn’t appear for me to choose it in Source Data. However I don’t want to count bugs I want to count all Linked Issues (any kind of link and any kind of issue type). Could you help me please?

Hi @Kananda_S_Silveira,

Yes, many examples are based on the custom Bugs link dimension built by adding the definition of the linked incidents dimension to the eazyBI advanced settings. Please see the documentation with several definition examples on how to do it: Import issue links

Suppose you want to see the count of all issue links for each issue. In that case, you might use a bit different approach and import linked issue count as a new custom measure “Count all links” using a JavaScript calculated custom field. The definition and code for custom measure might look like this:

# Counter of all links as measure
[jira.customfield_count_links]
name = "Count all links"
data_type = "integer" 
measure = true
javascript_code = '''
var issuelinks = new Array();
var counter = null;
if ( issue.fields.issuelinks ) {
  var links = issue.fields.issuelinks;
  for (var i = 0; i < links.length; i++) {
var link = links[i];
//count outward links that are not to epics or sub-taks    
if (link.outwardIssue) {
  if( link.type.outward != "is Epic of" & link.type.outward != "jira_subtask_outward") {
    issuelinks.push(link.outwardIssue.key);
    counter = counter+1;
  }
}
else
//count inward links that are not to epics or sub-taks
if( link.type.inward != "has Epic" & link.type.inward != "jira_subtask_inward") {
  issuelinks.push(link.inwardIssue.key); 
  counter = counter+1;
}
}
  issue.fields.customfield_count_links = counter;
}
'''

Add this code to eazyBI advanced settings and save changes. Then go to import options, tab Custom fields, and select Count all links for data import as measure and as property.

Lauma / support@eazybi.com

3 Likes

how would I modify this to only count links that are a certain issue type, i.e. Bugs?

Hi @JoEllen_Carter!

In JavaScript, you could add a check for link.outwardIssue.fields.issuetype.name == "Bug" (or similarly for the inward issue type link.inwardIssue.fields.issuetype.name == "Bug").

However, counting only bugs is described in my second reply above; if there can be several link types for the bug dimension, you can also specify them in the advanced settings. See this post: Linked bugs and multiple types of links.

Lauma / support@eazybi.com