Calculating Total user stories based on epics fields

Hi there

We are using eazyBI with JIRA. Our Epics have features, and features have user stories.
I need to calculate the number of USs that exist under epics which have specific values that are being selected in the page section.
The filters include the following 2 dimensions: [Target PI] and [Label]

I have written the following measure to check based on selected Target PI but it’s taking ages to execute (I guess it’s because it’s going through all USs in the system):
Count(
Filter(
Descendants([Issue.SAFe].CurrentHierarchyMember, [Issue.SAFe].[User Story]),
[Issue].CurrentHierarchyMember.Parent.Parent.get(‘Target PI’) = [Target PI].CurrentMember.Name
)
)
Is it correct to write it this way? Can you advise how to make this more efficient?
And how can I add a condition to filter the epics so to only those that have Label “XYZ” ?

Thanks a million

Hi,

The formula is generally correct for counting the Stories having the Target PI of grandparent matching the PI from the report context. You are also right that this approach has a significant risk of performance problems.

There are a couple of techniques to make such calculations more efficient. First, it is possible to define a new Javascript calculated custom field that would inherit down the Target PI from the upper level of the hierarchy down to the User stories. This approach is limited to work with the single value custom fields in Jira.

You can add to the advanced settings of eazyBI the lines like this:

[jira.customfield_cf_inherited]
name = "Target PI Inherited"
data_type = "string"
dimension = true
javascript_code='''
if (issue.fields.customfield_NNNNN ) {
  issue.fields.customfield_cf_inherited=issue.fields.customfield_NNNNN
}
'''
update_from_issue_key = "epic_key" ## use the correct id of the upper hierarchy level

You need to use the custom field ID instead of NNNNN and the correct name of the level ID instead of the “epic_key”. Once you import this field as a dimension, the simple filtering in the report pages should do the count (you may also add the Issue type filter in the report).

In the case of the Labels, it is possible to create a similar construction using the Issue link field dimension.
You can see a similar example of configuration here:
https://docs.eazybi.com/eazybijira/data-import/advanced-data-import-options/issue-link-field-dimensions#Issuelinkfielddimensions-FeatureLabel

Kindly,
Janis, eazyBI support

Thank you very much for this suggestion.
We’ll definitely try it as it’s not possible to work with the current performance.

Hi, I have used this code and I get an error.
code:
[jira.customfield_commitment_inherited]

name = “Commitment Level Inherited”

data_type = “string”

dimension = true

javascript_code=’’’

if (issue.fields.customfield_17500 && issue.fields.customfield_17500.value) {

issue.fields.customfield_commitment_inherited=issue.fields.customfield_17500.value;

}

‘’’

update_from_issue_key = “epic_key” ## use the correct id of the upper hierarchy level

[jira.customfield_technical_epic_inherited]

name = “Technical Epic Inherited”

data_type = “string”

dimension = true

javascript_code=’’’

if (issue.fields.customfield_17726 && issue.fields.customfield_17726.value) {

issue.fields.customfield_ technical_epic_inherited=issue.fields.customfield_17726.value;

}

‘’’

update_from_issue_key = “epic_key” ## use the correct id of the upper hierarchy level

Error:
JavaScript code raised the following error:
missing ; before statement

Can you please advice what did I do wrong?
My intention is inheriting the customize data on the epic (Commitment Level and Technical Epic) to all children (stories, tasks, sub-tasks)

Please, send the details to support email for more detailed checking.
An additional screenshot of where the settings are added would be helpful.

Kindly,
Janis, eazyBI

Hi! I’m having problems with this script

[jira.customfield_mpc_e]
name = "Epic MPC Type name" 
data_type = "string"
dimension = true
update_from_issue_key = "epic_key"
javascript_code = '''
if(issue.fields.customfield_17704 ) {
   issue.fields.customfield_mpc_e = issue.fields.customfield_17704;
}
'''

error: Execution of custom JavaScript code raised the following error:
unterminated string literal

Anyone knows why?