I would like to automate a calculation through automation rule.
Here, I have a task having custom field = X (numeric)
X= (A+B)/C, where
A&C= custom field of Task
B= sum of custom fields of child of Task
Here, A&C are numeric values and B is calculated value created through app.
Now, B is not a field (only used for calculation purpose)
Option1 - Solution I have tried (didn't work):
The rule run successfully. But no output as such.
Option 2 - The solution worked:
Is there a way if I can go with option 1 without creating field B?
Hi @Sreelal CS
Created variables are text strings and so they usually need to be converted to numbers for use in math expressions: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#asNumber
For your example of a variable named "x" divided by a number custom field, customfield_34567:
{{x.asNumber.divide(customfield_34567)}}
Kind regards,
Bill
Hi @Bill Sheboy
I created 2 variables in Jira automation. One is {{WIPnumber}} and the other is {{All}}
I converted them using asNumber to divide them and I want to update the result in a number field.
My formula is like
{{WIPnumber.asNumber.divide(All.asNumber)}}
But the result is always 0. At the same time, I update custom fields with these variables and it works fine. And I use the value of these custom fields to do the math, it also works fine.
Below is how I edit my custom field value.
{{issue.customfield_10035.divide(issue.customfield_10034)}}*100
Does it mean I can't calculate 2 variables even I converted them to numbers? Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Yi Meng
First thing, this is a very old thread, and so I recommend creating new questions for such cases, and perhaps adding a link back to the older one for context. That will ensure the maximum number of people see it to offer suggestions.
Next, when a created variable is converted with asNumber for inline math expressions, the type (integer or floating-point) is preserved from left-to-the-right. And so if your WIPnumber variable is an integer, the division will be integer-based, truncating any decimal digits.
To get a floating-point result, use the long-format of math expression:
{{#=}}{{WIPnumber}} / {{All}}{{/}}
You may add the ROUND() function when you want to manage the precision of the result.
To learn a lot more detail about using created variables as numbers, please see this recent article I wrote on the topic:
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.
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.