Calculated field from two other fields' values

Jure Jerebic August 30, 2024

Hi everyone,

We have a requirement to take two fields' values (Urgency and Impact), both of which have levels 1-4 that can be selected, and calculate the average of those two into a third field (Priority). This has to happen either when an issue (of a particular request type) is created or when the Impact field is updated. How can we configure this automation most effectively?

Thanks!

2 answers

0 votes
Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

Welcome to the community @Jure Jerebic 

First you need to identify the IDs' for both of the custom fields that have been created. You would need to create the automation rule when the issue gets created for the specific issue type (unless this applies to all of the issue types).

For the action you would need edit issue and to select the Priority field - make sure that this field is different from the already existing system field - my suggestion give it a different name.

Basic calculation: {{issue.customfield_10486}} + {{issue.customfield_10487}}

Since you need average, do the addition of two custom fields then depracte it with 2.

Jure Jerebic August 30, 2024

What would I set as the trigger? I need this to run whenever an issue of that request type is created or the Impact value is updated

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

You can use only one of the triggers:

  • Issue created - when the issue is created the automation rule will run
  • Field value change - here you define when the field value change is happening for Impact then do the action
Like Jure Jerebic likes this
Jure Jerebic August 30, 2024

That's what I thought as well, so I'll have to create two automations. Thanks!

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

@Jure Jerebic Not quite. Only one when the issue is created then to do the calculation for the Impact field, which is done with Edit issue action.

So it would be like this:

  • Trigger: Field value changes - here you will specify both Impact and Urgency
  • Action: Edit issue - Impact field will be edited where in the input field you will be putting the calculation between the Urgency and Impact
Jure Jerebic August 30, 2024

No, I meant two different automations for:

1. issue is created -> do the calculation and update the final calculated field
2. issue is updated (Impact is edited - we won't change the Urgency) -> do the calculation and update the final calculated field

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

Ah, I didn't know you want to do the calculation twice. But, yes in that case, you would need two. Also, if you found my answer helpful, please mark it as accepted as there might be other people asking this question, so they can reference it easier.

Jure Jerebic August 30, 2024

@Nikola Perisic I'll set it up next week and let you know, much appreciated for the time being!

Jure Jerebic August 30, 2024

I can't seem to add the calculation into the Edit Issue action, I can only pick between the options that are available there; I also don't know what exact calculation I should use to get the average of two fields; note that this field that should be calculated is a single select field - or do they have to be text fields?

Screenshot 2024-08-30 at 13.54.46.png

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

To find the average of two numbers, you should sum them first then divide by 2. You need to replace the {{issue.customfield_xxxx}} with the IDs' of your custom fields that you are doing the calculation for. To find the IDs', navigate to Settings > Issues > Custom fields. Find your fields and click on Edit details.

Screenshot 2024-08-30 at 14.41.55.png

In the address bar you will see ID showing. In my case it's 10052, yours will be different.

Jure Jerebic August 30, 2024

Would this syntax be correct? 

{{#=}}({{issue.fields.Impact}} + {{issue.fields.Urgency}}) / 2{{/}}

Also, I still cannot add that syntax into the automation to add it into that field, does it have to be a free text field?

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

It's not correct, since you need to use the {{issue.customfield}}, please refer to the previous comment.

Jure Jerebic August 30, 2024

So this then:

{#=}}({{issue.customfield_11870}} + {{issue.customfield_11051}}) / 2{{/}}

What about the issue of not being able to add this to the destination field in the automation?Screenshot 2024-08-30 at 14.59.51.png

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

{#=}} is not needed. Also the field has been specified which is Priority.Also for value changes you need to add the Urgency as well.

Jure Jerebic August 30, 2024

I only want to change the value of Priority:

1st source field: Impact (values 1-5)
2nd source field: Urgency (values 1-5)
Calculated end field: Priority (values 1-5)

This should happen in two scenarios:

1. a new ticket is created

2. value of Impact is edited on an existing ticket

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

To better explain:

1.When the new ticket gets created, Priority gets calculated based on the formula from the screenshots

2. I see, it was not mentioned by the way that this is for the existing ticket. Nevertheless, Priority is based on the calculation of Impact and Urgency

What supposed to be a confusion here? Maybe I do not understand it as well.

Jure Jerebic September 2, 2024

Correct, so it should use that formula. However, I can't paste the formula into the field in the worklow, see the screenshot above

0 votes
Dexter de Vera
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

Hi @Jure Jerebic ,

Welcome to the Atlassian community,

You can follow this sample automation:

Trigger: Field value changed - impact

Condition:

If or Else Add condition option:

        If block:

                    Add condition -

                                Issue field condition - Impact equals 1

                                Issue field condition - Urgency equals 1

                   Action: Edit field - Priority - low

       Add else (If else)

                 follow the condition and action then change the value

     So on and so forth until you align all the condition and value.

image.png

You can check this list of documentation to learn more about creating and configuring Jira cloud automation.

https://support.atlassian.com/cloud-automation/docs/create-and-configure-jira-automation-rules/ 

Hope it helps.

Thank you

Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

Hi @Dexter de Vera , @Jure Jerebic  is looking for calculating two fields,not just the automation set up.

Jure Jerebic August 30, 2024

Nikola is correct, I don't want to set up a whole line of all the possible calculations through conditions

Like Nikola Perisic likes this
Dexter de Vera
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

@Nikola Perisic Alright. On my own understanding based on the description of this question, I think his looking for a condition based on the value selected in the dropdown list (Urgent and Impact) and then select the appropriate Priority. But yes, you can explain to him based on what you understand. Thanks!

Dexter de Vera
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2024

@Nikola Perisic Alright. you may follow the instructions of @Nikola Perisic  answer.

Thank you!

Like Nikola Perisic likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events