JIRA Misc Custom Fields - Calculated Number

Hello, I need some help as I am a groovy/beanshell newb!

I am trying to take the highest value of 3 number fields (risk1, risk2, risk3) and multiply that by a fourth number field (probability) to set a 5th value (residual risk rating). Can anyone steer me in the right direction, maybe give some example code? I've looked around on this tag and have not seen anything similiar! Any help would be greatly appreciated. 

2 answers

You can create a Calculated Number Field, and in the description of that field (Field->Edit), type something like:

<!-- @@Formula:
if (issue.get("<field4>")==null) 
  return null;
Double m = 0;
if (issue.get("<field1>") != null && issue.get("<field1>") > m)
  m = issue.get("<field1>") ;
if (issue.get("<field2>") != null && issue.get("<field2>") > m)
  m = issue.get("<field2>") ;
if (issue.get("<field3>") != null && issue.get("<field3>") > m)
  m = issue.get("<field3>") ;
return m * issue.get("<field4>"); 
-->

where <field1> ... <field4> are the names of the four Number fields. Note that:

1) these fields must be Number fields - not text fields containing a number (otherwise some conversion is required)

2) the sample code above returns null if any of the fields is null - you might want a different strategy, such as ignoring empty fields 1 to 3.

This works great. Thank you so much for this. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 11, 2018 in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

2,484 views 5 6
Join discussion

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