How to automate the sum of story points for all issues under the epic?
Asked by hassan_ahmed:

I would like to know if there is a way I can automate the sum of story points for each issue under the epic?

For example, if I have a task and a bug card each worth 2 story points each, can this be totaled on the epic (parent) level to read 4?

If not possible for all issues, can this be done for tasks only under the epic (not subtasks)?

Hope this makes sense to more experiences users.

Many thanks


Answers:
author: Gareth Cantrell
body: [@hassan_ahmed](/t5/user/viewprofilepage/user-id/4193861) you can do this with Automation rules with the following rule, assuming you are using Jira Cloud:

Whenever the Story Points field changes, branch the rule for the related Epic and then sum all the Story Points for issues belonging to the Epic.

The following screenshot show how this would look:

![Screenshot 2021-02-10 at 14.01.08.png](https://community.atlassian.com/t5/image/serverpage/image-id/129774iE369D7855FB0761D/image-size/large?v=v2&px=999 "Screenshot 2021-02-10 at 14.01.08.png")

comments: author: hassan_ahmed
body: Thank you for the suggestion [@Gareth Cantrell](/t5/user/viewprofilepage/user-id/3178836) . This works great!


author: Mohini Chandwani
body: Hello,

trying to create the same rule but couldn't get this lookup Issue component, is there any other alternative for this.

Can refer the following screenshot of my rule.![sum up rule.png](https://community.atlassian.com/t5/image/serverpage/image-id/129977i1CAA6092C88D57B5/image-size/large?v=v2&px=999 "sum up rule.png")


author: hassan_ahmed
body: [@Mohini Chandwani](/t5/user/viewprofilepage/user-id/4260550) Hi Mohini.

* Remove the "If" issue so the "for epic (parent)" branches off the first step.
* Then press "new actions" \> "lookup issues" and type "Epic Link" = {{issue.key}} \> save
* "new action" \> "edit issue" and search story points
* type in {{look up issue code}} and save


author: Mohini Chandwani
body: Even after removing the "If" condition didn't get the option of "lookup issues".

![look up issue.png](https://community.atlassian.com/t5/image/serverpage/image-id/129986i87FB32362C98CF58/image-size/large?v=v2&px=999 "look up issue.png")

Is this related to scope or access?


author: hassan_ahmed
body: When you press new action you should see these options?

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/129988iB81D43545C467A73/image-size/large?v=v2&px=999 "image.png")


author: Gareth Cantrell
body: [@Mohini Chandwani](/t5/user/viewprofilepage/user-id/4260550) I see you tagged your original [question](https://community.atlassian.com/t5/Automation-questions/Can-we-sum-up-the-story-points-of-all-child-issues-and-update/qaq-p/1609329) as Cloud, however your screenshot suggests you're using the Server version.

Unfortunately the Lookup issues action is not yet available on the Server version.

This can be achieved in the Server version using a Send web request to query the Jira Software REST API in place of the Lookup issues action.

In the following rule, I'm using a web request to the same Jira instance using the Webhook URL: *{{baseUrl}}/rest/agile/1.0/epic/{{issue.key}}/issue?maxResults=100*where {{issue.key}} is referring to the Epic in the branch rule.

You also need to set the *Authorization* header using base64-encoded credentials of a user with access to the project.

Additionally, you need to select the **Wait for response** option.

![Screenshot 2021-02-11 at 15.14.55.png](https://community.atlassian.com/t5/image/serverpage/image-id/129998i0BEA1F64E92B6A07/image-size/large?v=v2&px=999 "Screenshot 2021-02-11 at 15.14.55.png")

The final piece of the puzzle is to use the response from the web request to sum up the story points into the Epic.

In my instance, the custom field id of the *Story Points* field is *customfield_10106*.

![Screenshot 2021-02-11 at 15.15.09.png](https://community.atlassian.com/t5/image/serverpage/image-id/129999i02DA9E128DD10233/image-size/large?v=v2&px=999 "Screenshot 2021-02-11 at 15.15.09.png")


author: Mohini Chandwani
body: Hello,

I have tried the same, but it throws the error - Response HTTP status : 500 and same Webhook URL run in the browser and getting the data.

And in header I have provided Authorization and encoded {username:password}, other steps are same but still the same error.

Thank you for your valuable suggestions.


author: Gareth Cantrell
body: [@Mohini Chandwani](/t5/user/viewprofilepage/user-id/4260550) The only thing I can suggest is to make sure the {{baseUrl}} is what you expect it to be (you can do this using the *Log action* component).

It can happen depending on how your instance and any proxies are configured, that you may need to use http://localhost:8080 instead of {{baseUrl}}.


author: Mohini Chandwani
body: Thank you [@Gareth Cantrell](/t5/user/viewprofilepage/user-id/3178836) for all your suggestions, the issue was in the baseURL but it is resolved.

Rule is working correct.

Thanks.


author: Mohini Chandwani
body: Hello [@Gareth Cantrell](/t5/user/viewprofilepage/user-id/3178836)

Is there any way to send email when rule gets failed or any error occurs.

Can we keep the check for Audit log status whether the rule is ran successfully or some error occured.

I have tried the following approach but it is not sending mail.

![mail.png](https://community.atlassian.com/t5/image/serverpage/image-id/149487iB645D42B4E137FBC/image-size/large?v=v2&px=999 "mail.png")

Any open suggestion with better option which has quick implementation is welcome.

Thanks.


author: Gareth Cantrell
body: Hi [@Mohini Chandwani](/t5/user/viewprofilepage/user-id/4260550)

In the rule details section, you can select to be notified if the rule fails and select the rule owner who will receive these notifications as in the below screenshot:

![Screenshot 2021-07-10 at 21.02.47.png](https://community.atlassian.com/t5/image/serverpage/image-id/150852iF792572959EC6F81/image-size/large?v=v2&px=999 "Screenshot 2021-07-10 at 21.02.47.png")


author: Mohini Chandwani
body: Hi [Gareth Cantrell](https://community.atlassian.com/t5/user/viewprofilepage/user-id/3178836),

Have tried the same but it is not sending the mail.

Is there any way to access the audit log status value like "SUCCESS" or "SOME ERRORS" so that we can send the mail based on status response, I have tried to console like {{Audit log.Status}} etc various combinations but didn't print anything.

Let me know if it is possible.

Thanks for always responding!


author: Gareth Cantrell
body: [@Mohini Chandwani](/t5/user/viewprofilepage/user-id/4260550) you could try looking at {{webhookResponse.status}} which will return the [HTTP Status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for last web request action.


author: Julien Rey
body: Hi everyone, I just wrote a KB article describing how to create an automation rule that will sum up all the story points of stories linked to a parent Epic ticket in Automation for Jira for Server/Data Center.

Can you take a look and let me know if it helps?

<https://confluence.atlassian.com/jirakb/automation-rule-to-add-sum-up-story-points-from-all-the-stories-linked-to-an-epic-1108083641.html>

comments: author: Wyner_ Zachary G_
body: [@Julien Rey](/t5/user/viewprofilepage/user-id/1133380)

This method works well, but not for existing epics that have stories with story point values already assigned. This method only adds story points to the epic story point total when the value of story points in a single story is changed.

It would be helpful to include a way to do a one-time sum of all story points in an epic for existing epics. Once that initial sum is generated, this method works well.

Thanks,  
Zac


author: Julien Rey
body: [@Wyner_ Zachary G_](/t5/user/viewprofilepage/user-id/4472170)

Thanks for your feedback. That's a great point indeed. The solution I wrote will only work indeed for freshly created Epic/Stories, but not for ones which already have story points assigned.

It is unfortunately difficult to find a solution without having the lookup method which only exists in Automation for Jira on Cloud :(


author: Sagar
body: The below automation rule can help here to achieve this on Jira server/datacenter version without using any authentication method.

* **WHEN**
  * **Field value changed**: Story Points
* **Issue fields condition**
  * **Field**: Issue type
  * **Condition**: Equal
  * **Value**: Story
* **If: matches** (you need to add a new if/else block, with an "Advanced compare condition")
  * **First value** :  

    ```
    {{fieldChange.fromString}}
    ```

  * **Condition**: Equals
  * **Second value**: empty

![Capture 2022-01-11 at 17.44.54.png](https://community.atlassian.com/t5/image/serverpage/image-id/177231i4B76255F6D07727C/image-size/large?v=v2&px=999 "Capture 2022-01-11 at 17.44.54.png")

*
  * Add a **Branch rule / related issues** inside the **IF block** :
    * **Type of related Issues**: Epic (parent)
  * **THEN** (to place inside the branch rule)
    * **Choose field to set**: Story Points
    * **Value** :  

      ```
      {{#=}}{{issue.Story Points}} + {{fieldChange.toString}}{{/}}
      ```

![Capture 2022-01-11 at 17.45.14.png](https://community.atlassian.com/t5/image/serverpage/image-id/177232i748502596576691A/image-size/large?v=v2&px=999 "Capture 2022-01-11 at 17.45.14.png")

* **Else**
* Add a **Branch rule / related issues** inside the **ELSE block** :
  * **Type of related Issues**: Epic (parent)
* **THEN** (to place inside the branch rule)
  * **Choose field to set**: Story Points
  * **Value** :  

    ```
    {{#=}}{{issue.Story Points}} + {{fieldChange.toString}} - {{fieldChange.fromString}}{{/}}
    ```

![Capture 2022-01-11 at 17.55.34.png](https://community.atlassian.com/t5/image/serverpage/image-id/177234iCDB1764BEA785328/image-size/large?v=v2&px=999 "Capture 2022-01-11 at 17.55.34.png")

![Capture 2022-01-11 at 17.44.24.png](https://community.atlassian.com/t5/image/serverpage/image-id/177235iFFA8F40868109CD1/image-size/large?v=v2&px=999 "Capture 2022-01-11 at 17.44.24.png")


author: Andreas Safar
body: I was trying different proposals but it does set the sum value of story points to the epic.

See my logic here

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/152568iD1110550DAF76925/image-size/large?v=v2&px=999 "image.png")

and here

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/152569iBC4511264A41ACFA/image-size/large?v=v2&px=999 "image.png")

so when the rule is enabled and I set or change story points in a story I'm getting no error

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/152570iC9716C2B1EFFBEE2/image-size/large?v=v2&px=999 "image.png")

but when I reload the epic and check for the story points field, it remains empty

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/152572iC79702872446C866/image-size/large?v=v2&px=999 "image.png")

Did I misunderstood something, do you see an error in my logic or do you have a proposal on how to proceed?

Thx


author: Wyner_ Zachary G_
body: [@Gareth Cantrell](/t5/user/viewprofilepage/user-id/3178836)

Thank you for the workaround for summing story points into the Epic story points field! I am using JIRA server so I've been looking for a solution to this issue.

My rule runs without errors but the story point field in the Epic that should be updated is not being updated. Furthermore, if the Epic has a story point value it is erased when this rule runs.

Here is a screenshot of the rule. Any ideas?

![Automation.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/150845iE2406B37C4B2B803/image-size/large?v=v2&px=999 "Automation.PNG")

comments: author: Gareth Cantrell
body: [@Wyner_ Zachary G_](/t5/user/viewprofilepage/user-id/4472170) I'd suggest adding a *Log action* after the *Send web request* action and the log the value of your custom field from the web response to make sure the values you are getting back are what you are expecting to see.


author: Wyner_ Zachary G_
body: [@Gareth Cantrell](/t5/user/viewprofilepage/user-id/3178836) Thanks for the fast response! I added a log action but it seems like the value being returned by the web request is the story point value for the epic, which is null.

![Automation2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/150857iA3CD77C43A340F9C/image-size/large?v=v2&px=999 "Automation2.PNG")


author: Gareth Cantrell
body: [@Wyner_ Zachary G_](/t5/user/viewprofilepage/user-id/4472170) as you say, you're logging the field in the epic. Try logging the response from the web request instead: {{webhookResponse.body.issues.fields.customfield_10002}}


author: Wyner_ Zachary G_
body: [@Gareth Cantrell](/t5/user/viewprofilepage/user-id/3178836)

Getting closer! According to the log, the web request is retrieving the values I am expecting and the rule successfully executes. However, it still nulls out any value in the Epic "story points" field rather than summing the story point values from each story.

![Automation3.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/150902i233573DECD1F05C0/image-dimensions/450x494?v=v2 "Automation3.PNG")


author: Wyner_ Zachary G_
body: [@Gareth Cantrell](/t5/user/viewprofilepage/user-id/3178836)

Just letting you know I got the rule to work! I had to change the formula in the edit issue fields action to this:

{{webhookResponse.body.issues.fields.customfield_10002.join("+")}}

Thanks for your help!

-Zac


author: Gareth Cantrell
body: Great to hear you managed to get it working, although I am surprised the sum() function didn't work for you.

May be worth raising a support request with Atlassian to investigate.

Cheers,

Gareth


author: Mohini Chandwani
body: Hi @[Wyner_ Zachary G_](https://community.atlassian.com/t5/user/viewprofilepage/user-id/4472170),

I guess the problem is in the web request URL, it is returning null because you didn't mention customfield of Story point to retrieve the story point value from those issues.

Can you just try these once - **{{baseUrl}}/rest/agile/1.0/epic/{{issue.key}}/issue?customfield_10002** it will return the story point values of all child of their Epic parent.

sum function should work, I am using the same approach it adds all the child story points and total will be added to respective epic parent.

refer the below snap.

![story point.png](https://community.atlassian.com/t5/image/serverpage/image-id/153486i4BB156BF88845A58/image-dimensions/140x110?v=v2 "story point.png")

Hope it should work.


author: Rahul_RVS_Support
body: Hi

You can try out our add-on to track progress of issues in Epic hierarchy on time estimates and at story points as well.

[Agile Tools - Epic Tree and Time in Status](https://marketplace.atlassian.com/apps/1223200/agile-tools-epic-tree-time-in-status?hosting=cloud&tab=overview)

The add-on allows you to manage and visualize your Epics with rolled up estimate progress reports along with multiple Time in Status Reports ( more than 6 reports).

Key features:

* Epic Hierarchy
  * Epic Sum up - Roll up for Time estimates and Story Points
  * Excel like editing for key fields
  * Excel export of hierarchy dataProgress % on "remaining estimate" or "original estimates"
  * Include all issue types vs only Stories in Story Points roll up
  * Support for custom names for Epic \& Story fields

* Multiple Time in Status reports
  * Report Types
    * Time in Status
    * Time with Assignee
    * Time in Status with Assignee
    * Time with Assignee per Status
    * Status/Assignee Count
    * Multiple Transition Reports

  * Configurable working hours/days
  * Excel export

* Transitions tracking on issue screen
  * Status/ Assignee Transition : Status/Assignee changes with average time and count per status. Option to switch between Graphical and tabular view.
  * Epic Tree on Issue Screen

![Epic Hierarchy Screen_Server_Latest.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/137713i0D2EA429FDE4EB21/image-size/large?v=v2&px=999 "Epic Hierarchy Screen_Server_Latest.PNG")

![TISwA-5-Apr.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/137714iE2B6238E26D0C2BC/image-size/large?v=v2&px=999 "TISwA-5-Apr.PNG")


author: Jack Brickey
body: Maybe consider the Epic Sum Up addon. There is a lite (free version) - [epic-sum-up-light](https://marketplace.atlassian.com/apps/1213331/epic-sum-up-light?hosting=cloud&tab=overview)

comments: author: Andreas Haaken _APTIS_
body: Hi Jack,

thank you for recommending Epic Sum Up. The free Version sums up Time only, but the full version sums up everything you want.

Looks like this:

![screenshot-jira.aptis.info-2022.02.08-16_52_44.png](https://community.atlassian.com/t5/image/serverpage/image-id/182302iCBF128A6D8A6092A/image-size/large?v=v2&px=999 "screenshot-jira.aptis.info-2022.02.08-16_52_44.png")