Forums

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

Divide one field by another field and store the output in new custom field

Sangmesh February 25, 2021

Hello,

I have a request to create a calculated custom field.

I have 2 fields,

  1. UST Adjusted - Number field
  2. Time Spent(Hours) - System Field

User want to divide UST Adjusted by Time Spent and store the output in a new custom field Productivity.

For this, I created a Calculated Number Field by JWT and wrote the formula as,

Math/Numeric expression:   {UST Adjusted}/{Time Spent}

But, It is not working for me. I am not sure, why!

For that I tried to search on community and found this - https://community.atlassian.com/t5/Jira-Software-questions/Divide-one-Number-field-by-another-number-field-and-add-output/qaq-p/1381732

When I found some script in the link, I am not sure where to write it in my Jira instance. I don't have a script runner plugin installed.

Could you please help me create a calculated custom field?

Also, Time Spent is filled after the issue is solved, So User wants it to work whenever the time is logged on the issue (if time is not logged at the beginning)

@Nic Brough -Adaptavist- 

@Martin Bayer _MoroSystems_ s_r_o__

Thanks,

Sangmesh

 

 

 

 

2 answers

1 accepted

6 votes
Answer accepted
Jona Ittermann [Decadis AG]
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.
February 25, 2021

Hi @Sangmesh

your JWT calculated number field might not work with the current expression, if the fields are empty. So you might want to update your expression to something like this (if you are using JWT >= 3.0):

{issue.timeSpent} != null and {issue.cfaaaaa} != null ? {issue.cfaaaaa} / ({issue.timeSpent} / 60) : null

 

For JWT < 3.0 your expression would be:

{00025} != null and {aaaaa} != null ? {aaaaa} / ({00025} / 60) : null

where aaaaa is in both cases the field code of the field "UST Adjusted".

I also added the ... / 60 ... because the total time spent field returns the time in minutes and this way we transform the output to hours.

 

With this expression, the calculated number field will be empty as long as not both fields are set. As soon as both are set, the value will be calculated and displayed. But this logic can also simply changed by updating the expression in front of the question mark.

 

Cheers

Jona

Sangmesh March 2, 2021

Hello @Jona Ittermann [Decadis AG] ,

This works fine for me.

Thanks !!

Regards,

Sangmesh

0 votes
Nic Brough -Adaptavist-
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.
February 25, 2021

You will need to install one of the scripting apps to do this, or use Automation for it (which won't do it with a script)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events