percentage calculation in Jira

Akeem Ibrahim April 6, 2023

Hello Gurus,

I have this issue to configure on JIRA with Automation rule in the custom fields, to give result anytime issue created to get the percentage of issue ranked. They are as follow as example:

1. Dining Set = 40%.    2. Furniture set = 40%.        3. Kitchen set =20%     Total =100%.

a. Table =40%                    C.table =38%                       Oven =35%

b. Chair =32%                    Sofa =40%                            D.washer = 35%

c. table cloth =28%            stool =22%                           Microwave = 30%

with 1, 2, 3, being an  issue, and their dropdown are the issue class underneath. I want the condition in automation to have the following result:

Result Priority:

Highest = >70%

High = 50% -69%

Medium =30% - 49%

low = 20% - 39%.

I am currently an app on JIRA (JMWE), but i am still finding it difficult to get the result. 

1 answer

0 votes
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.
April 6, 2023

Hi @Akeem Ibrahim 

Using automation rules often requires learning and experimentation.  I recommend trying to build your rule, and if you run into challenges post your rule and audit log so the community can help.

To get you started, I believe you can do what you ask with the new Lookup Tables feature, and/or conditions and math expressions.  Please look here for more information:

Kind regards,
Bill

Akeem Ibrahim April 11, 2023

Hello Bill,

Many thanks for helping out. I am still facing errors in the "Automation", i have attached some result pictures here. What i tried to do this time was to just take 2 issues and see if i could automate the weighted average.Web capture_11-4-2023_105828_tunde847.atlassian.net.jpegWeb capture_11-4-2023_105811_tunde847.atlassian.net.jpegWeb capture_11-4-2023_105655_tunde847.atlassian.net.jpegWeb capture_11-4-2023_10555_tunde847.atlassian.net.jpegWeb capture_11-4-2023_105314_tunde847.atlassian.net.jpeg

 

This are  the errors, i am facing with the automation. Kindly look into this if there could be any correction.

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.
April 11, 2023

First thing: when posting images of your automation rules, please post the image of the entire rule.  This can be done using a screen capture tool, such as one that can scroll the browser tab.  When you post multiple images for pieces of a rule it can be difficult to see the overall context.

Next, also post the image of the entire audit log details for the rule execution.  That will show at what point the rule had problems.

From what I can see of your rule...

In the first image showing Edit Issue Fields, the section for "Additional fields" may only contain JSON.  What you show is not well-formed JSON.  And, JSON usually only needed when your field is not listed in the drop-down list for edit.  To learn how to write well-formed JSON for fields, please look here: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

Next, when referencing a field in a rule, you may use {{issue.fieldName}} rather than {{issue.fields.fieldName}}

Finally, in the Advanced Compare Condition and in the Create Variable action, you have a smart value expression which does not make sense to me.  That are you trying to do with the expression below? 

{{[ | percent(0.6012 )]}}
Akeem Ibrahim April 12, 2023

Hello Bill,  Thanks for you support. I followed the steps you highlighted from previous post. I created the automation in the following:

1. Issue to triggers rule:

2. I created variables as the "actions"

3. I created "Look up table" for all the variables for their percentage value.

4. Then I created edit field in "Action" to put the calculation. here is the weighted average calculation in smart value:  {"Business Worth"} =| percent(0.4012) * {"Operational cost"} =| percent(0.6512) * {"Cosmetic Change"} =| percent(0.3512) + {"Risk and Regulatory Compliance"} =| percent(0.4012) * {"Internal Control"} =| percent(0.6012) * {"Customer Facing"} =| percent(0.4012) + {"Capability and continuity"} =| percent(0.2012) * {"Yes to Strategic Planning"} = | percent(0.7512) * {"more than twelve months"} =| percent(0.2501)/100

5. The edit field to have the percentage is a numerical custom field,  and i still get the error.

Here are the picturesWeb capture_12-4-2023_13033_tunde847.atlassian.net.jpeg

This was the error i received above.

Web capture_12-4-2023_12524_tunde847.atlassian.net.jpegWeb capture_12-4-2023_125344_tunde847.atlassian.net.jpegWeb capture_12-4-2023_125437_tunde847.atlassian.net.jpegWeb capture_12-4-2023_125627_tunde847.atlassian.net.jpeg

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.
April 12, 2023

A few more things before we can try to fix those errors:

  • You seem to be using the pipe character | in several places.  In automation rules, I believe that is only used for default values and formatting of tables in output formatting.  I do not think either applies so you can remove them.
  • Next, for the Create Lookup Table, you cannot use smart values in the Key value.  You can only use plain text key values.
  • Smart values are name, spacing, and case-sensitive.  I suspect you have one or more incorrect smart values, based on what you show. 

After you address those things, please try your rule again and then let's see what the audit log shows for any errors.  Thanks!

Akeem Ibrahim April 13, 2023

Hello Bill,

Thanks for the support. Regarding the observation about pipe character | , i used one of the app in jira (JMWE) and the field smart value was written in that way for percentage. I wanted the variable to represented with percent, so that i can do the calculation correctly. I also use Visual Studio Code to verify the smart value calculation with JSON. I have attached the screenshot here for you see.

Screenshot (3).pngWeb capture_13-4-2023_93817_tunde847.atlassian.net.jpeg

All i wanted is to do the weighted average calculation, and have the result display in the custom field (numeric), and the only numeric custom field in JIRA does not allow that. I will try again with your suggestion maybe it will work if i remove the pipe character, and change the key value.

Akeem Ibrahim April 13, 2023

Hello Bill,

I am here again to update you on progress i have made so far.  

A.    I edited "calculated field01" to put the JSON for the following:

  1. If the weighted average percentage is greater than or equal to 70%, then the priority of the issue should be set to "Highest".
  2. If the weighted average percentage is between 50% and 69%, then the priority of the issue should be set to "High".
  3. If the weighted average percentage is between 30% and 49%, then the priority of the issue should be set to "Medium".
  4. If the weighted average percentage is between 20% and 39%, then the priority of the issue should be set to "Low".

B. I did not change any of the previous Automation in the "Look up Table". with all the Automation rule, it came as "Success", but the only thing remain is to calculate the weighted average which would come before "IF" condition in the Automation rule. Here is the screenshots for you to see.

Web capture_13-4-2023_12730_tunde847.atlassian.net.jpegWeb capture_13-4-2023_121352_tunde847.atlassian.net.jpegWeb capture_13-4-2023_121512_tunde847.atlassian.net.jpeg

 

Thank you for your support.

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.
April 13, 2023

Some things to note...

Just because something works in Visual Studio, or another tool outside of Jira, that does not mean it will work in Jira automation rules.  The documentation notes in a couple of places that some things are based-upon other implementations, like for Java's regular expression implementation, but it does not state what is different.

Next, just because a rule audit log indicates "success" that does not mean the rule did what you wanted...It only means it did not have an error.

Would you please provide the smart value expression you are using to calculate the weighted average, in text format?  With the amount of adjustments I am unclear what the current version is, and seeing that may help to identify what is happening.

Thanks!

Like Akeem Ibrahim likes this
Akeem Ibrahim April 13, 2023

Hello Bill,

This is the smart value expression i intend to use to calculate weighted average: 

{"Business Worth"} =| percent(0.4012) * {"Operational cost"} =| percent(0.6512) * {"Cosmetic Change"} =| percent(0.3512) + {"Risk and Regulatory Compliance"} =| percent(0.4012) * {"Internal Control"} =| percent(0.6012) * {"Customer Facing"} =| percent(0.4012) + {"Capability and continuity"} =| percent(0.2012) * {"Yes to Strategic Planning"} = | percent(0.7512) * {"more than twelve months"} =| percent(0.2501)/100.

I don't know which action to use in automation to get the calculation correctly.

 

Thanks,

Akeem

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.
April 13, 2023

That syntax does not match either format which works for Automation for Jira rules.  The two syntaxes for math operation are chained operations or the basic math operations.  Either ones of these can be used in an Edit Issue Action or other actions.

Example of chained math operations:

{{issue.myCustomField1.multiply(issue.myCustomField2).plus(issue.myCustomField3)}}

Example of basic math operations:

{{=#}}({{issue.myCustomField1}}*{{issue.myCustomField2}})+{{issue.myCustomField3}}{{/}}

 

You have repeatedly shown a math operation which I believe will not work with a rule, so please try to use one of the above formats.

 

To try to help you further it would help to know:

What are the names and types of fields you are using?  For example, is "Business Worth" and issue field, a value of an issue field, or something else?  What about "Operational cost" and the other things you note?

You seem to be repeatedly using Created Variables in your math expressions, but it is unclear where they are getting any values. What are the sources?

And, to help post an image of your entire rule in one image, I suggest looking for a browser addon (or screen capture application) which can scroll the browser while capture the image.

Akeem Ibrahim April 14, 2023

Hello Bill,

I have changed the maths operation now to this: 

(({Business Worth} * 0.40) + (({Operational cost} * 0.65) + (({Cosmetic Change} 0.35) + (({Risk and Regulatory Compliance} * 0.40) + (({Internal Control} * 0.60) + (({Customer Facing} * 0.40) + (({Capability and continuity} * 0.20) + (({Yes to Strategic Planning} * 0.75) + (({more than twelve months} * 0.25))/1

The name field in the issue are: 

  • Business Worth =   Operational cost , cosmetic change.
  • Risk and Regulatory =  Internal control, Customer facing.
  • Capability and Continuity = Yes to strategic planning, more than twelve months.

I created a look table to get the source of the value for the fields here is the screenshot:

Web capture_14-4-2023_93939_tunde847.atlassian.net.jpeg

For the rules, i created variable from actions for each field as variable, and "percentage value" as the name of look up table, then i used edit issue field as my "calculated issue field 10" to do the math operation, and then used the advance value of the same "calculated issue field10" to do the following:

  1. If the weighted average percentage is greater than or equal to 70%, then the priority of the issue should be set to "Highest".
  2. If the weighted average percentage is between 50% and 69%, then the priority of the issue should be set to "High".
  3. If the weighted average percentage is between 30% and 49%, then the priority of the issue should be set to "Medium".
  4. If the weighted average percentage is between 20% and 39%, then the priority of the issue should be set to "Low".

Web capture_14-4-2023_101946_tunde847.atlassian.net.jpeg

Web capture_14-4-2023_9342_tunde847.atlassian.net.jpeg

I guess i am doing something wrong because there no result to show in the issue page.

 

thanks,

Akeem

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.
April 14, 2023

Hi, Akeem.

My recommendation is that you pause what you are doing, and go have a chat with your Jira site admin to explain the scenario you are trying to solve, and ask for their help.  They may be more effective as I appear unable to explain the rule features and syntax to you.  I also recommend that you pause and review the introductory information on automation rules.

 

Before you ask your Jira site admin for help, I'll try again to explain some things I see in what you just posted:

(1) Smart values for fields  in rules use in this format: {{field_or_variable_name}}  but you continue to only use one set of curly-brackets, like this {field_or_variable_name}  and that cannot work.

(2) I asked you what are the names of the fields, and you replied with this as an example:

Business Worth = Operational cost , cosmetic change.

From that, I cannot tell if you have one field with two choices, three fields, or something completely different.  Please clarify this before you talk to your Jira site admin.

(3) You cannot use smart values in the Key for a Create Lookup Table action.  You can only use a text value.  Please review the documentation for more information: https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Create-lookup-table

(4) When using the Edit Issue action, with More Options, only valid JSON for rules is accepted.  You cannot use any other format as the rule cannot understand that.  Please review the documentation for more information: https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Edit-issue and https://support.atlassian.com/cloud-automation/docs/jira-smart-values-json-functions/

Like Akeem Ibrahim likes this

Suggest an answer

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

Atlassian Community Events