Forums

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

Calculated field not working

LWRET2015 September 28, 2018

Trying to set up a calculated value in JIRA. We have the value of ROI and PO but can't seem to define INC properly. Something like...

<!-- @@Formula: 
def ROI = getCustomFieldValue("customfield_10914")
def PO = getCustomFieldValue ("customfield_10913")

integer INC = 
(issue.get("customfield_14008") != null ? (float) Integer.parseInt(issue.get("customfield_14008")) : 0 ) +
(issue.get("customfield_14010") != null ? (float) Integer.parseInt(issue.get("customfield_14010")) : 0 ) +
(issue.get("customfield_14011") != null ? (float) Integer.parseInt(issue.get("customfield_14011")) : 0 ) +
(issue.get("customfield_14012") != null ? (float) Integer.parseInt(issue.get("customfield_14012")) : 0 );

return ROI*INC/PO
-->

I looked around on the forums and think that I found a more accurate formula but I am sure my syntax is wrong in some way.

<!-- @@Formula:

integer i =
(issue.get("customfield_14008") != null ? (float) Integer.parseInt(issue.get("customfield_14008")) : 0 ) +
(issue.get("customfield_14010") != null ? (float) Integer.parseInt(issue.get("customfield_14010")) : 0 ) +
(issue.get("customfield_14010") != null ? (float) Integer.parseInt(issue.get("customfield_14011")) : 0 ) +
(issue.get("customfield_14010") != null ? (float) Integer.parseInt(issue.get("customfield_14012")) : 0 );

(issue.get("customfield_10914") != null ? (float) Integer.parseInt(issue.get("customfield_10914")) : 0 ) *
(i != null ? (float) Integer.parseInt(i) : 0 ) /
(issue.get("customfield_10913") != null ? (float) Integer.parseInt(issue.get("customfield_10913")) : 1000000 )

-->

Any assistance would be much appreciated.

1 answer

0 votes
LWRET2015 September 28, 2018

I figured it out already. It was 

<!-- @@Formula:

Object cf1 =
(issue.get("customfield_14008") != null ? (float) Integer.parseInt(issue.get("customfield_14008")) : 0 ) +
(issue.get("customfield_14010") != null ? (float) Integer.parseInt(issue.get("customfield_14010")) : 0 ) +
(issue.get("customfield_14011") != null ? (float) Integer.parseInt(issue.get("customfield_14011")) : 0 ) +
(issue.get("customfield_14012") != null ? (float) Integer.parseInt(issue.get("customfield_14012")) : 0 );

(issue.get("customfield_10914") != null ? (float) Integer.parseInt(issue.get("customfield_10914")) : 0 ) *
cf1 /
(issue.get("customfield_10913") != null ? (float) Integer.parseInt(issue.get("customfield_10913")) : 1000000 )

-->

Thanks to anyone that looked.

Sid
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.
September 28, 2018

hi @LWRET2015,

I am also looking for a calculated field, your solution might help me. Can you explain your fields use cases or what are functionality of these fields 

thanks 

LWRET2015 October 1, 2018

It may be a bit difficult to explain the purpose for each field but I can certainly explain their relationship in the formula. 

Formula for the first calculated field is (not mentioned in this post)...

single select field 1 (value of 0-3) +
single select field 2 (value of 0-3) +
single select field 3 (value of 0-3) +
single select field 4 (value of 0-3) +
= calculated field 1 (text value of 0-12, each value returns a separate text description)

Original formula for the second calculated field (which is what this post was about) is...

single select field 5 (value of 1-10) multiplied by
calculated field 1 (value of 0-12) divided by
single select field 6 (value of 1-10)
= calculated field 2 (number field)

The trick with the second formula is that I could not use calculated field 1, because it was a text field (i wanted a description in the value). So I had to recalculate the the value from the first formula to get a number value in the second formula. So the second formula ended up being more like...

single select field 5 (value of 1-10) multiplied by
[single select field 1 + 2 + 3 + 4] divided by
single select field 6 (value of 1-10)
= calculated field 2 (number field)

Basically my main issue was syntax though. I had to clean up the equation using the proper characters and terms. I was able to piece it together using a bunch of different examples from the Atlassian Community. I didn't come up with this from scratch myself. lol.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events