Sum numeric values from a custom field
Asked by Andreas Safar:

For better capacity planning we introduced the custom fields "FE-Estimates" and "BE-Estimates".

Both are numeric fields.

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

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

So now I want to sum all values from all stories into the same custom field within an Epic.

How can I do that?

I tried the following but it's not working![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/152577iDCDB7ABBFB2E9B1F/image-size/large?v=v2&px=999 "image.png")


Answers:
author: Bill Sheboy
body: Hello, community!

As noted in the other answers for this question, summing custom fields with **Jira Cloud** may use the Lookup Issues action: <https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Lookup-issues>

However for **Jira Server and Data Center** , the initial version of Lookup Issues does not support all fields yet. Please watch / vote here to see progress on that work: <https://jira.atlassian.com/browse/JIRAAUTOSERVER-877>

The work-arounds for Server and Data Center versions depend upon what you want to do with the sum value(s):

* If you need them for a message / email, and your rule does not have any existing branches, you could try the bulk-handling feature: <https://confluence.atlassian.com/automation/run-a-rule-against-issues-in-bulk-993924653.html> This provides the {{issues}} smart value (and note that one is plural), and so the same list functions, like sum, may be used.
* However if your rule is already using a branch for something else, please try calling the REST API function for an issue search with JQL, using the Send Web Request action. The response's body is a list of issues. To learn about using this technique, please look here:
  * <https://community.atlassian.com/t5/Jira-Software-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828>
  * <https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html#Jirasmartvaluesissues-webhookResponsewebhookResponse>

Using that second method, a custom field is summed like this:

```
{{webhookResponse.body.issues.fields.customfield_12345.sum}}
```

If you run into problems, remember to write the response body to the audit log and confirm you have the correct smart values for your fields.

Kind regards,  
Bill

comments: author: Jack Brickey
body: Excellent write up Bill. This is sure to help others.


author: Timur Khakimyanov
body: I just spent few hours trying to implement Bill Sheboy second proposal, and finally success! Hope this post will help someone to save time:

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

No rocket science, but you have to be very careful about parameter names and such.

comments: author: Bill Sheboy
body: Hi [@Timur Khakimyanov](/t5/user/viewprofilepage/user-id/4546279) -- Welcome to the Atlassian Community, and well done!

The part I find interesting about your web request, custom data is passing the entire {{lookupIsssues}} smart value rather than parsing the keys/id values out into a CSV list, such as: {{#lookupIssues}}{{key}}{{\^last}},{{/}}{{/}}

Looks like your version works for you, and so meets the goal!

Kind regards,  
Bill


author: Andreas Safar
body: Hi [@Timur Khakimyanov](/t5/user/viewprofilepage/user-id/4546279) thank you for your post. I' ve copied your solution and it works for me.


author: Jack Brickey
body: You cannot sum values across all stories. The automation math functions work within an issue. So you can sum two numeric fields within an issue. You might need to look at some add-on for this.

comments: author: Bill Sheboy
body: Hi [@Andreas Safar](/t5/user/viewprofilepage/user-id/4294100) -- Welcome to the Atlassian Community!

Yes, and...to what Jack noted: Are you using the Server or the Cloud version?

I note you are trying to sum custom field values with Lookup Issues.

* First, Lookup Issues is only supported for Cloud. The equivalent for Server is a scheduled JQL rule which uses the "batch" option.
* If you are on Cloud, Lookup Issues [only supports a limited number of fields](https://support.atlassian.com/jira-software-cloud/docs/smart-values-general/#Smartvaluesgeneral---lookupIssues--) at this time. Here is the suggestion to add more fields: <https://jira.atlassian.com/browse/JRACLOUD-75018>

Best regards,  
Bill


author: Andreas Safar
body: Thank you for your reply. We are using the cloud version.

In other threads I saw comments where the story points or time estimates are summed up in the appropriate fields of their epic. So I was hoping to do the same just with the custom fields. Something like this:

Story 1 has value '5' in custom field

Story 2 gets a '3' entered into the custom field

Both stories are linked to the same epic

-\> custom field within the epic gets updated from '5' to '8'

and so on when the custom field is set/changed/removed


author: Bill Sheboy
body: Andreas you cannot sum on custom fields with Lookup Issues in an automation rule, yet...

Two possible work-arounds are:

1. Whenever a field of interest changes in a child issue, update the parent using the [Change Log](https://support.atlassian.com/jira-software-cloud/docs/smart-values-general/#Smartvaluesgeneral---changelog--). The risk here is getting out of synch if the rule does not trigger or when multiple issues change in a short timeframe.
2. Using a [webrequest, the REST API](https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828), a [search filter](https://docs.atlassian.com/software/jira/docs/api/REST/1000.824.0/#api/2/search-search), and [text functions](https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/), get all of the issues for the parent and then convert the webrequest response into a [list...using sum to add up the results](https://support.atlassian.com/jira-software-cloud/docs/smart-values-lists/#Smartvalueslists-list.sum). The impact is this rule is several seconds slower, but it will be accurate.


author: Andreas Safar
body: Hi Bill, thank you again for your support. I've voted for JRACLOUD-75018

I'll try to handle it with the proposed work-arounds.

Just for your reference in the meantime I've tried the following:

With the following rules the custom field on the parent issue is changing from NULL to 0

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

see the history:

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

I'm getting the same effect with

{{lookupIssues.customfield_10066.sum}}

{{Issues.customfield_10066.sum}}

{{lookupIssues.fields.customfield_10066.sum}}

{{Issues.fields.customfield_10066.sum}}

{{lookupIssues.subtasks.fields.customfield_10066.sum}}

where the following has no impact on the epic issue

{{Issues.subtasks.fields.customfield_10066.sum}}


author: Bill Sheboy
body: Yup... {{issues}} (note the plural) is a Server version smart value used in conjunction with that batch/scheduled trigger I noted. It doesn't work for Cloud version.

The equivalent for Cloud version batch processing is Lookup Issues...and that feature does not support custom fields.

Please see the two work-around ideas I offered to see if one of those will work for you. Thanks!


author: Dennis Hansen
body: Custom fields are now supported in Lookup Issues: <https://community.atlassian.com/t5/Automation-articles/New-lookup-issues-fields/ba-p/1873978>


author: Bill Sheboy
body: Hi [@Dennis Hansen](/t5/user/viewprofilepage/user-id/434847)

This issue was resolved long ago for Jira Cloud, but still exists for [Jira Server / Data Center automation rules](https://jira.atlassian.com/browse/JIRAAUTOSERVER-877). I am curious, what is the purpose of your post?

Thanks, and kind regards,  
Bill


author: Tomislav Tobijas
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

I've just stumbled upon this limitation on DC. Regarding possible workarounds you've [mentioned](https://community.atlassian.com/t5/Automation-questions/Re-Re-Sum-numeric-values-from-a-custom-field/qaq-p/1759673/comment-id/1887#M1887), particularly 2nd method - how can you convert the webhook response to a list? I've sent a REST API web request (JQL) and got several issues as a result there. With that (response), how can you convert that to a list and use *list.sum* function?

On webhook response, I've tried {{webhookResponse.issues.customfield_XYZ.sum}} but that ain't working ?

Cheers,  
Tom


author: Bill Sheboy
body: Hi [@Tomislav Tobijas](/t5/user/viewprofilepage/user-id/3848395)

You are quite close to the answer...It helps to post the entire response to the audit log and confirm the response structure as that will show using both the *body* and *fields* to get at the data.

```
{{webResponse.body.issues.fields.customfield_12345.sum}}
```

That works for me for Jira Cloud, so please confirm it for your Data Center rule.

Kind regards,  
Bill


author: Tomislav Tobijas
body: You're a lifesaver [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ?

I've been struggling with web response as there's only one browser I can use in this specific environment and it doesn't format JSON response automatically (+all online formatters are also restricted by network security policy).

Anyway, I've tested it on this DC environment and it works perfectly! The only difference is that webhook responses are accessible via

```
{{webhookResponse}} 
```

while on cloud it is

```
{{webResponse}}
```

Cheers,  
Tom


author: Jack Brickey
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) , it might be worthwhile pulling out the details of the answer into a separate answer and then [@Tomislav Tobijas](/t5/user/viewprofilepage/user-id/3848395) or I could accept it.


Tags: custom-field