Create a calculated field showing a percentage

Hi all, I would appreciate it of someone could help me here. I'm completely new to JIRA and have no background as a user. I'm sure what I'm asking is actually fairly simple but I cant get it to work. 

Essentially I have two number fields and I want to create a third which shows a percentage of the two. So simply: 

 

Formula.JPG

 

I have attempted this using a calculated number field and some "script":

<!-- @@Formula: (issue.get("customFieldId=10427") &divide; issue.get("customFieldId=10007") : 0)–>

 

This has not worked and even if it had I'm not sure it would show a percentage anyway.

 

I understand I could use a scripted field which I have the add in to do but I don't know where to start with that.

 

Help much appreciated smile 

 

2 answers

0 vote

Hey there,

I recommend you to use the add-on JIRA Misc Custom Fields to achieve this. Please take a look on their documentation at the following link:

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

 

--Arthur Gonçalves

Hi Arthur, thanks for this. This is where I actually referenced to do the first attempt at the HTML in my original question. Can you see anything wrong with what I had attempted because its not returning any values: <!-- @@Formula: (issue.get("customFieldId=10427") &divide; issue.get("customFieldId=10007") : 0)–>

try this: <!-- @@Formula: (issue.get("customfield_10427") != null ? issue.get("customfield_10427") : 0) / (issue.get("customfield_10007") != null ? issue.get("customfield_10007") : 0) -->

Hi Sy, that definitely gets values in the field so a step closed I'd say! Not a percentage though, will that have to be done through a scripted field as you have done below? I'll give that a shot

Have you tried using a scripted field? I use that for a lot of calculations, and setting it as a text would allow you to add the % symbol as well.

Its with the Script Runner Plugin: https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted+Fields

Here you can set your custom fields but using getCustomFieldValue("Custom Field Name")

and then perform the calculations you want and then returning the answer, if you need the percentage sign you can set it to return as a text searcher have something like

 

return "% " + answer

Which would end up something like this that you can use:

try{
//Retrieve two dates
w = getCustomFieldValue("Custom Field Name 1")
x = getCustomFieldValue("Custom Field Name 2")

//If Statement to check for nulls
if(w &amp;&amp; x != null){

//Calculating and saving answer
double answer = w/x as double

//displaying(returning) the answer
return answer
}
}
catch(Exception e)
{
}

If you'd like to do this through a post function then a post function is available called "Mathematical or date-time expression calculator " Through the plugin JIRA Workflow Toolbox, here you can calculate as well using different fields.

I'd like to add that the answer I've done is only dividing two fields which contain numbers, if you want to do a percentage calculation then e.g You may calculate something like double difference = w-x as double double division = difference/w as double double answer = division*100 as double return answer this for example will give you the difference between w and x in a percentage.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

64 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you