Story point completion rate not getting correctly calculated
Asked by Saili:

We have these 2 automation in place for tracking our EPIC progress. BUt the problem is whenever we delete or move any child issue from that EPIC then the story points of it are still getting considered in the 'Story points completed'. 'Story points total' is getting changed. Due to this the completion rate in % of the EPIC is getting displayed incorrect. This incorrect data is also then getting reflected in our Salesforce end. Please let me know how can I correct this. As in the EPIC life cycle there are supposed to be many changes in the child issues which is now being a problem in calculation of its completion rate.![2024-06-10_13h46_01.png](https://community.atlassian.com/t5/image/serverpage/image-id/328907i3214EFC8AEDE2394/image-size/large?v=v2&px=999 "2024-06-10_13h46_01.png")![2024-06-10_13h46_22.png](https://community.atlassian.com/t5/image/serverpage/image-id/328906iA74E15E1AF3D059E/image-size/large?v=v2&px=999 "2024-06-10_13h46_22.png")


Answers:
author: Bill Sheboy
body: Hi [@Saili](/t5/user/viewprofilepage/user-id/5409858)

First thing, **how are you linking Epics to their child issues** : using the built-in mechanism with the parent field in the child issues or some other way (e.g., with issue links)? The two rules you show indicate both methods, and so I hypothesize *your existing rules do not work as you explain.*

Back to your original question...

If an child issue is closed, that implies it is completed. **Why would a completed child issue be moved to another parent Epic or deleted from Jira?**

Assuming there is a valid scenario for doing this, you will need two additional rules to handle those cases:

* One triggered on a change to the parent field, and then both the current and previous epics will need updates to their total story points
* One triggered on issue delete, and then the previous epic will need an update to the total story points

Kind regards,  
Bill

comments: author: Saili
body: Dear [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) [@Stevan Mandi?](/t5/user/viewprofilepage/user-id/5497872)

I m sorry for mentioning closed issues.

Also we wish to calculate the story points from issues which are linked using built in mechanism and not with the option of 'linked issues'.  
So when any child issue is moved or a linked issue is added, at that time the calculation is getting wrong. Can you please suggest a solution for this.

Thanks in Advance!

Saili


author: Saili
body: There is also this automation in place which I suspect is not working fine too

![2024-06-17_16h11_41.png](https://community.atlassian.com/t5/image/serverpage/image-id/330171iE33ADF7F956D992D/image-size/large?v=v2&px=999 "2024-06-17_16h11_41.png")


author: Bill Sheboy
body: For the rule image you show immediately above this post \^\^\^

I assume the scheduled trigger uses JQL to find the epics, and the Lookup Issues action then tries to find the child issues of each epic for updates.

First, smart values are case-sensitive. Please change the JQL in that Lookup Issues action to this:

```
parent = {{issue.key}} AND issuetype != Epic
```

Next, please show the details of the Edit Issue action to confirm the expression used to set the field.

If your project is Company-Managed, they use the "Story Points" field, with the smart value of {{issue.Story points}} and so the edit would probably use this:

```
{{lookupIssues.Story points.sum|0}}
```

If instead your project is Team-Managed, they use the "Story point estimate" field, with the smart value of {{issue.Story point estimate}} and so the edit would probably use this:

```
{{lookupIssues.Story point estimate.sum|0}}
```


author: Saili
body: Also can you please let me know how to only consider the story points from parent child built in mechanism and not from the 'linked issues'.  
Our project is company managed. Here are the edit details  
![2024-06-18_13h31_20.png](https://community.atlassian.com/t5/image/serverpage/image-id/330358i726427C020C0B304/image-size/large?v=v2&px=999 "2024-06-18_13h31_20.png")


author: Bill Sheboy
body: Please adjust the case to match what I posted earlier, including the default value of 0 when no issues have story point values:

```
{{lookupIssues.Story points.sum|0}}
```

The rule you showed using the Lookup Issues should work correctly to update the epic for the child issues.

If it is not, please post an image of the audit log details showing the rule execution.


author: Saili
body: I adjusted the case. But the main issue still exists where the story points from linked issue is still getting considered in the story point completed.

Can you please make a suggestion?

![2024-06-21_11h29_23.png](https://community.atlassian.com/t5/image/serverpage/image-id/331063iEE2A7FC4652C1D50/image-size/large?v=v2&px=999 "2024-06-21_11h29_23.png")![2024-06-21_11h32_26.png](https://community.atlassian.com/t5/image/serverpage/image-id/331064i5F4EA7F75C0B7F17/image-size/large?v=v2&px=999 "2024-06-21_11h32_26.png")


author: Bill Sheboy
body: Earlier you noted using the **parent field** to connect Epics to child issues. This is the default, built-in behavior. But your rule does not show that.

If you are using the built-in parent field, please update your rule as follows:

* trigger: issue transitioned to Closed
* condition: issue type is one of Story, Task, or Bug (and your other standard types)
* branch: to Parent of the issue
  * action: lookup issues, with the JQL:
    * parent = {{triggerIssue.parent.key}} AND status = Closed
  * action: edit issue to update the field from the lookup results


author: Stevan Mandi?
body: Hi [@Saili](/t5/user/viewprofilepage/user-id/5409858) ,  
As [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) said, you have inconsistent Epic-child linking (I suggest you use parent-child relation). Also I agree that you will need 2 additional rules: one for issue deletion and other for parent change.  

I will provide a solution for parent change:  

Prerequisites:

* Built-in Parent-child relation through Parent field.
* Add simple text custom field: LastParent  

* Create temporary scheduled automation (you only need to run it once) that populates children LastParent field with parent key (So initially, every issue has current parent key populated in LastParent field. The value of LastParent should be set to: {{issue.parent.key}}

<br />

<br />

Create an automation:

<br />

![Screenshot 2024-06-10 at 19.03.14.png](https://community.atlassian.com/t5/image/serverpage/image-id/328974i66456A0B2E4D4C17/image-size/large?v=v2&px=999 "Screenshot 2024-06-10 at 19.03.14.png")

\*For Edit story points action(sum) use: {{lookupIssues.Story Points.sum}}

_______

This automation covers following scenarios:

1. Child issue removed from epic - Calculation is performed on that epic
2. child issue parent field changed from empty (parent set) - LastParent field is populated with the key of new parent and calculation is performed for Parent.
3. Child issue moved from epic to another epic- Calculation is performed on both epics.
4. Child issue created under epic - LastParent is populated with parent key
5. Child created through create Button and story points set - LastParent is populated with parent key and calculation is performed on Parent epic.  

\*Also, use your 2 already created rules, and Create automation that will be triggered by child issue deletion.  

<br />


Tags: cloud

jira-cloud