Calculate Sum of Custom Field by user

Scott Herdman August 31, 2014

I have a custom field that has a numerical value, 0.1, 0.5 1.0 etc,

Looking for way to track calculate the sum of this field by user using a JQL query.

e.g. if i have 4 issues assigned in a project with the values 0.1, 0.25, 0.5 and 0.5 it would return my user with value 1.35 plus similar respnces for all other people with assigned ticket where the value of the custom field isnt empty

3 answers

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2014

Typically this is what reports and gadgets are for as Nic said.

However this was the use case for the aggregateExpression JQL function in Script Runner. If there are multiple different users in your filter you should get a data table with a value for the sum of the values by user. If you get the function params right...

Scott Herdman September 1, 2014

As far as i can tell this just produces an alert that is suited to grand totals. I really need this break down per user and subtotals in a jql from that i can then refine further for diffrent reports

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 31, 2014

It's important to think of where you expect this field to occur for the user - gadget? Report? On an issue?

Sumit Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2014

Later that Calculated Number field can be used anywhere in Jira/ Jira related tools.

Sumit Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2014

This can be achieved easily by creating a Calculated Number Field and simple formula

https://innovalog.atlassian.net/wiki/display/JMCF/JIRA+Misc+Custom+Fields

Formula will be something like:

<!-- @@Formula:

Object cf1 = issue.get("customfield_10600");

Object cf2 = issue.get("customfield_10601");

Object cf8 = issue.get("customfield_10015");

int number = cf1 + cf2 + cf8;

return number;

-->

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 31, 2014

The question was about JQL, and different issues. The code you've given adds up fields on the same issue.

Scott Herdman September 1, 2014

I really need in a query essentaily the same as an Excel Subtotal with a sum on the custom field

Essentilly producing somthing smilar to the below (Dont care about Grand Totals)

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 1, 2014

But where do you want the field to appear in Jira?

Scott Herdman September 2, 2014

As a new field in the JQL results

0 votes
Ansar Rezaei
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2014

Hi

You can do it by using Groovy Runner. I have another post (https://answers.atlassian.com/questions/310666/calculate-field-value) want something like you and I did it by using groovy runner.

p.s: This link is belong to my previous Atlassian ID and as I couldn't change my email address, I sing up for another one.

Suggest an answer

Log in or Sign up to answer