Forums

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

Automation rule to calculate current and target score

Khalid El-Bialy June 18, 2025

I am looking to enable simple equation which is being done easily in Excel :

 

  • Current Score = (Weight % × Current Maturity Level number) / 5
  • Target Score = (Weight % × Target Maturity Level number) / 5

i have around 14 blocks/epics that have the , current set up , 

  1. current and target maturity levels field as a dropdown list with five options "L1,L2,L3,L4,L5".
  2. Weight %: number field that has a specific number that indicate the weight of each epic example "11% per epic number 1 
  3. current and target score filed : that is also numbers.

so if we consider i am selecting drop down in current maturity level as : L2 the equation should be calculate as example ( 11*2/5 = 4.4) and 4.4 should automatically reflect in the current score field.

so if we consider i am selecting drop down in target maturity level as : L3 the equation should be calculate as example ( 11*3/5 = 6.6) and 6.6 should automatically reflect in the target score field.

I have tried many automation rule, none has works as i am facing  challenging converting the text field to number so the math would work, anyone can help ?

Last equations i have used and returned with error cannot convert to number :

 

 

    • set the "Current Score" field:
      {{issue."Weight %".toNumber.default(0)}} * {{if(issue."Current Maturity Level".value.equals("L1"), 1, if(issue."Current Maturity Level".value.equals("L2"), 2, if(issue."Current Maturity Level".value.equals("L3"), 3, if(issue."Current Maturity Level".value.equals("L4"), 4, if(issue."Current Maturity Level".value.equals("L5"), 5, 0)))))}} / 5
    • Set the "Target Score" field:
      {{issue."Weight %".toNumber.default(0)}} * {{if(issue."Target Maturity Level".value.equals("L1"), 1, if(issue."Target Maturity Level".value.equals("L2"), 2, if(issue."Target Maturity Level".value.equals("L3"), 3, if(issue."Target Maturity Level".value.equals("L4"), 4, if(issue."Target Maturity Level".value.equals("L5"), 5, 0)))))}} / 5

 

 

the following is the Log for the error showing : 

 

Field value changed06/18/2025, 14:33:36
Expand
Edit work item06/18/2025, 14:33:36
Collapse
Could not convert the field value to a number. Please ensure the value is a number, math expression or smart-value that can be converted into a number.
Current Score: set the "Current Score" field: * 2 / 5, Target Score: Set the "Target Score" field: * 4 / 5
Re-fetch work item data06/18/2025, 14:33:37
Expand
Log action06/18/2025, 14:33:37
Collapse
Log
Weight %: 11.0 Current Maturity Level: L2 Target Maturity Level: L4

2 answers

1 accepted

1 vote
Answer accepted
Bill Sheboy
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.
June 18, 2025

Hi @Khalid El-Bialy -- Welcome to the Atlassian Community!

First, what version of Jira are you using: Cloud, Server, or Data Center.  That impacts the supported features of automation rules.

 

Next, I recommend pausing to review the documentation for how math expressions work with smart values: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/

Reading this you will find several things in your expression are not valid syntax.

 

Finally, as your maturity custom fields' dropdown values contains the number with an "L" character prefix, that could be removed and the result used in the math expression.

 

Putting that all together, perhaps try this expression, assuming your fields all have values selected and that your smart values are correct:

Current Score:

{{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}


Target Score:

{{#=}}0{{issue."Weight %"}} * 0{{issue."Target Maturity Level".value.substringAfter("L")}} / 5{{/}}

 

And, if you need to manage the significant digits, perhaps add the ROUND() function to the expression.

 

Kind regards,
Bill

Khalid El-Bialy June 18, 2025

@Bill Sheboy  thank you for your response, I Am using Jira cloud, it is also team managed where i have no admin privileges, I can only configure some field in my project and all but that's it, i cannot change the filed it self to number or any , actually by applying your rule this is the closest i have had so far, it is now executing the equation and showing the correct result in the log only, however in the "current score" field it is returning "0" but it is still failing, the following is the log : 

 

Could not convert the field value to a number. Please ensure the value is a number, math expression or smart-value that can be converted into a number.
Current Score: Current Score: 4.4

debug: Current Score: 4.4

Bill Sheboy
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.
June 19, 2025

For more context, please post images of:

  • your complete rule,
  • the rule action where you try to update the field, and
  • the audit log details showing the rule execution

 

Khalid El-Bialy June 19, 2025

@Bill Sheboy 

attached the Epic config field, Rule builder, and log, 

 

BElow is the action added to edit the field current and target score.

 

Current:

Current Score: {{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}

 

Target:

Target Score: {{#=}}0{{issue."Weight %"}} * 0{{issue."Target Maturity Level".value.substringAfter("L")}} / 5{{/}}

Debug:

debug: Current Score: {{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}

 

rule.jpglog.jpgDCX1.jpgcurrent maturity dropdown config.jpg

Bill Sheboy
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.
June 20, 2025

Ah, you added the prefix text I put on the number calculation.  For example, "Current Score: "

When setting the number value in the Edit Work Item action, only include the math expression, such as:

{{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}

Like # people like this
Khalid El-Bialy June 24, 2025

@Bill Sheboy , 

 

Thank you for your support, your solution fixed the rule right away, if possible you can help out in this, following the same topic i am trying to create another automation rule to calculate the sum of all current and target score through all my 14 epics 

below what i have tried to do , i have created one more Task , and configured new four field 

DCX Overall Current score % --> number filed and it should return the current score value from all 14 epics ( DCX-1, DCX-2, ..etc) 

DCX Overall target score %--> "number filed "and it should return the target score value from all 14 epics ( DCX-1, DCX-2, ..etc) 

DCX Overall current level -->"text field" it should validate the score in the filed above DCX Overall Current score % fails under which level 

DCX Overall target level "text field" it should validate the score in the filed above DCX Overall Target score % fails under which level 

I have tried to use variable to store the data and just call this variable once more, however that did not work out and i keep getting frailer error to the rule.

 

(Trigger: when filed changes in any of the 14 DCX epics.

Actions: Find all 14 epics using keys (DCX-1 to DCX-14).

Calculate totals: Total Current Score = sum of all epics’ Current Score

Calculate Total Target Score = sum of all epics’ Target Score.

Update DCX Overall Summary " task" : with field "DCX Overall Current score % = Total Current Score;"

Update DCX Overall Summary " task" : with field DCX Overall target score % = Total Target Score".

update Overall Summary " task": field "DCX Overall current level" with value either (L1,L2,L3,L4,L5) "based on range per each level provided below" and the returned value on the field " DCX Overall Current score %"

update Overall Summary " task" :Field "DCX Overall target level with value either (L1,L2,L3,L4,L5) "based on range per each level provided below" and the returned value on the field " DCX Overall target score % "

1–29 = L1

30–49 = L2

50–69 = L3

70–89 = L4

90–100 = L5

Add a log to audit steps and detect failures.)

Screenshot 2025-06-24 144321.jpgScreenshot 2025-06-24 144428.jpgScreenshot 2025-06-24 144514.jpg

Bill Sheboy
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.
June 24, 2025

First thing: as your original question was answered, I recommend creating a new question for a new topic.  And if the two are related, perhaps including a link to the earlier one.  That will help focus the discussion and ensure more people see it to offer help.  Thanks!

 

For your new rule, I observe several things to check...

  • The rule is triggered on changes to several fields. Which work item do you expect to trigger the rule change?  That audit log error seems to indicate the specific one does not have the fields you are trying to edit, or those fields are not available on the edit view.
  • Next, you create two variables named totalCurrentLevel and totalTargetLevel. Later, the rule writes them with different names to the log: currentLevel and targetLevel. You may have also used the wrong names in the edit action.
  • Please show the details of your Edit Work Item action to confirm how the fields are set.
  • Finally, please review how you want your calculations to work. You seem to be describing summing / rolling up the percentage values. There are at least two ways to do this, and they will definitely produce different result values:
    • For the Epics, sum and average the percentages.  This will bias the percentages, giving more weight to scores from Epics with fewer child work items.
    • For the Epics, go back to their original child work items to gather them all and recalculate the percentage across them all. This will produce a more accurate value.

 

0 votes
Marc - Devoteam
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.
June 18, 2025

Hi @Khalid El-Bialy 

Welcome to the community.

Try using, issue."Current Maturity Level".value.replace("L1","1")

Or try {{issue.myCustomField.value.asNumber}}

Khalid El-Bialy June 19, 2025

that did not work as well 

Marc - Devoteam
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.
June 20, 2025

HI @Khalid El-Bialy 

On the edit action ,instead of using the field names, use the customfield_id.

So:

Current Score: {{#=}}0{{issue.customfield_xxxxx}} * 0 {{issue.customfield_xxxxx.value.substringAfter("L")}} / 5{{/}}

 

Find custom field ID; learn-multiple-methods-to-obtain-custom-field-ids-for-jira-and-jira-service-management-products 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events