Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble calculating percentage difference in Calculated Custom Field

Joe Charman
Contributor
September 19, 2018 edited

Hi all,

 

I'm using a calculated custom field from the Jira Misc Custom Field plugin.

Below is my formula to calculate the percentage difference between 2 budgets:

 

<!-- @@Formula: 

var basecost = issue.get("customfield_12104");
var actualcost = issue.get("customfield_13000");

var difference = actualcost-basecost;

var percentagediff = (difference/actualcost) * 100;

return percentagediff;


-->

 

As a test, with the base cost being 145000 and actual 157000, the calculation returns 7.643 in the custom field. 

 

Using the default windows desktop calculator and Google Calc, the result is: 8.275.

The field itself is a Calculated Text Field, and the customfield_12404 & 13000 referenced in the code are standard numerical fields.


Any ideas? Appreciate the help!

1 answer

1 accepted

1 vote
Answer accepted
AhmadDanial
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2018

Hi, Joe.

Via manual calculation, I received similar value for the percentagediff custom field, figure by figure:

basecost = 145000

actualcost = 157000

difference = 157000-145000

                    = 12000

percentagediff = (12000/157000) * 100

                          = 0.07643 * 100

                          = 7.643 %

So, I am not certain why Windows / Google Cal would give a different value here. Have you tried with different values and compare the results?

Joe Charman
Contributor
September 21, 2018

Hi Ahmad,

The issue was with one of the fields it was pulling through, it didn't seem to have the number in the right format.

I created it again and it all works now!

 

Thanks!

AhmadDanial
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 21, 2018

Hi there, Joe.

Awesome. Glad to know that we found the root cause to the problem. You are most welcome!

Suggest an answer

Log in or Sign up to answer