Hi, I'm trying to use automation to calculate the average of 2 custom fields and populate that answer in a 3rd custom field.
I would like to do:
Average = ((I Score) x (F Score)) / 2
This is currently the query I'm using:
{{#=}}{{issue.I Score}} + {{issue.F Score}} / 2 {{/}}
I have two questions:
1) when I use this formula, it just divides F Score by 2 - when I try to use parentheses for order of operations I get an error message. Any suggestions?
2) I would like the answer to round to the nearest whole number - how would I use the round functionality in this query?
Thank you!
Hi @Mariko Kelly -- Welcome to the Atlassian Community!
I wonder if this is related to the types of your fields. Are they both number fields, or something else?
And when you note using parentheses leads to an error, would you please show what you tried?
Another way to do this is to chain the operations, and add round to the end, such as this:
{{issue.I Score.plus(issue.F Score).divide(2).round}}
This format may reveal that the fields' smart values to not match what you expect. Those are name, spacing, and case-sensitive. One way to check the smart values is to use this how-to article's guidance: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
Kind regards,
Bill
Hi @Bill Sheboy
Thank you so much for your quick response / help!
{{issue.I score.plus(issue.F Score).divide(2).round}}
So, I ended up using your chain of operations and I validated that the fields' smart values are the same as I inputted.
Now, the automation is successful, but it doesn't output anything. I've shared some screenshots here - the output field is "Total Score"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let's try the simplest thing first...
The issue created trigger can fire before all of the issue fields are available to a rule. To slow down a rule and reload the data, please add the Re-fetch Action immediately after the trigger and then retest your rule.
Also...can the "I Score" and "F Score" fields change later, after an issue is created? If so, you may need a second rule triggered on changes to those fields to recalculate the "Total Score".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
I added the Re-fetch Action immediately after the trigger and the audit log said it was a success, however, it still is not populating any information in the Total Score field :( Is there anything else I can try?
I also double checked that all the custom fields are number fields...
Thank you so much for all of your help - I really appreciate it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
I was able to resolve this, almost!
I ended up using the following - this populated the a score into Total score, as expected/wanted:
{{#=}} ({{issue.I score}}/2) + ({{issue.F Score}}/2) {{/}}
However, when I try to use the round function,
{{#=}} round(({{issue.I score}}/2) + ({{issue.F Score}}/2)) {{/}}
I receive this error message in the audit log:
Error rendering smart-values when executing this rule:
Function round expected 2 parameters, got 1: round((2/2) + (5/2))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done, and...
When using that syntax for ROUND it takes a value and a precision: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/#Functions
Please try this:
{{#=}} ROUND(({{issue.I score}}/2) + ({{issue.F Score}}/2), 0) {{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.