Calculations possible in JIRA?

Nagaraju Reddy August 28, 2018

Hi Team

Can calculated values in Jira be done with using JMCF add-on?  For example, if I have a field called ‘Salary’ and another field called ‘Pay Cadence’ and a third field called ‘Rate Amount’, can it be done such that…

 

If ‘Pay Cadence’ = “Daily” then ‘Rate Amount’ = (‘Salary’/8)

Else If ‘Pay Cadence’ = “Hourly” then ‘Rate Amount’ = ‘Salary’

2 answers

2 accepted

1 vote
Answer accepted
Grigory Salnikov
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 28, 2018

Hi!

I think you can replace 'Pay Cadence' with 8 or 1 respectively and use the following formula:

'Rate Amount' = ('Salary') / ('Pay Cadence')

You can also have a small comment below the 'Pay Cadence' field explaining the numbers.

Nagaraju Reddy August 28, 2018

Can you suggest me sample code?

Grigory Salnikov
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 28, 2018

Let's say:

'Pay Cadence' - customfield_00001

'Salary' - customfield_00002

The calculation should be something like this:

<!-- @@Formula:

if (issue.get("customfield_00001") == null || issue.get("customfield_00002") == null)

return null;

return issue.get("customfield_00002")/issue.get("customfield_00001");

-->

All this needs testing. You'll never know what errors may emerge.

Grigory Salnikov
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 28, 2018

You can also always refer to the documentation.

Nagaraju Reddy August 28, 2018

Hi Greg,
I have created "salary " text field and "Pay Cadence" single select values 8 and 1, then I have created "calculated number field" called Rate amount and I have added code in description,
but rate amount field I am not able to see in my screens I am sure i have added the same to all screens I am missing that fields from my screen s

 Screen shot

salaty.PNG

and my formula
Salary = 10400 and Pay cadence = 10401
Screen shot:

pay.PNG

Grigory Salnikov
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 28, 2018

Use "Where's my field?" functionality:

wheresmyfield.jpg

Nagaraju Reddy August 28, 2018

Hi Greg,

Looks good checking with where is my field

Screen shot:

my field.PNG

Grigory Salnikov
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 28, 2018

Ok, there should be something wrong with the calculation itself.

Use this add-on to check atlassian-jira.log:

log.jpg

There will be displayed calculation-related errors.

Nagaraju Reddy August 28, 2018

Hi Greg,

Seems like formula error, can you look my formula above is it right?

Thanks

Nagaraju

Grigory Salnikov
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 28, 2018

What type are your fields? ('Salary' and 'Pay Cadence')

Grigory Salnikov
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 28, 2018

I have tested the behaviour in my environment and it works like a charm:

CNF.jpg

Nagaraju Reddy August 28, 2018

Hi 

I am using salary = number field type and pay cadance = single select type and rate amount = calculated text field (JMCF field) 

Grigory Salnikov
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 28, 2018

I think it's better to make "Rate Amount" a Calculated Number Field type.

It worked in my case.

Nagaraju Reddy August 28, 2018

Oh sorry Rate amount I have created calculated number field only. 

Grigory Salnikov
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 28, 2018

As long as you use a single select type field, I think it's better to do the following trick:

if (issue.get("customfield_10401").equals("1")) a = 1;

if (issue.get("customfield_10401").equals("8")) a = 8;

return issue.get("customfield_10400")/a;

You only have 2 options as 'Pay Cadence", right?

0 votes
Answer accepted
Grigory Salnikov
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 28, 2018

Oh, you can even save your initial 'Daily' and 'Hourly' :)

Nagaraju Reddy August 29, 2018

Hi Greg,

I have tried this, it is working super. and I am using initial 'Daily' and "Hourly' as well this is also working good.

Thank you Greg... reaily you responded soon and very clear inputs thank you so much for your help.

 

Thanks

Nagaraju

Grigory Salnikov
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 29, 2018

Hi, @Nagaraju Reddy!

Glad it worked :)

You also might want to mark the answer as accepted so that other people with the same or similar question would find it easily.

Have a nice day!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events