I have created an automation to work out the average of 3 numerical fields.
Action is to update an "Outcome" field using the below formula:
{{#=}}{{issue.customfield_10679.asnumber.plus(issue.customfield_10680.asnumber.plus(issue.customfield_10681.asnumber))}} / 3 {{/}}
All 3 custom fields are Smalltext fields which default to 0 and are for us to enter a number 0-100 (how successful that criteria was).
The goal is this automation to to update the Outcome field with the output of that calculation, whenever Fields 1, 2 or 3 are edited.
eg. field 1 contains 25, field 2 contains 50 and field 3 contains 75.
the Outcome field should output 50, and does so correctly.
My issue is when the output is a decimal and returns very long, messy numbers.
I have seen the .round smart value but cannot seem to get it to work with my formula.
Could someone please advise how my formula should look to round the output down to the next whole number, or even to 1DP?
Hi @Genevieve_Green,
I don't have a working environment where I can test, but given the complexity of your formula I suspect the best way to try and achieve what you're after may be through a ROUND() function.
Something like this:
ROUND(
{{#=}}{{issue.customfield_10679.asnumber.plus(issue.customfield_10680.asnumber.plus(issue.customfield_10681.asnumber))}} / 3 {{/}}
, 0)
That function is listed on the smart values, math expressions overview page and may even let you define the number of decimals to display.
Hope this helps!
Thanks for the quick response.
I tried the string provided and it did not error but also did not produce a desired outcome.
Output field contained
ROUND( 3.3333333333333335 , 0)
Instead of 3 or 3.33333333333 etc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just trial and error to be honest, but maybe that's because the function should be inside the math tags at the beginning and end.
{{#=}}
ROUND({{issue.customfield_10679.asnumber.plus(issue.customfield_10680.asnumber.plus(issue.customfield_10681.asnumber))}} / 3, 0)
{{/}}
If that doesn't work, you may want to look at @Bill Sheboy's suggestion too. I know he's often providing great answers about automation stuff 😀
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That second string did the trick, it' now returning correctly and to the nearest whole number.
Something else to add to my bag of tricks for automations :)
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And to mine as well 😀 - thx for the heads up!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried to chain the entire expression, including the division by 3, such as with this:
{{issue.customfield_10679.asNumber.plus(issue.customfield_10680.asNumber).plus(issue.customfield_10681.asNumber).divide(3).round}}
And...do you expect any of the values to be empty (i.e. null)? If so, considering adding a default value of zero to each with
.asNumber|0
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.