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?
Community moderators have prevented the ability to post new answers.
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
This topic has been locked because the thread has become a bit dated. If you’d like to keep the conversation going or have any more questions, feel free to start a new topic. You can read more about necro posting (“raising threads from the dead”) in our Community Guidelines .
Cheers!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You’re very close, the issue comes from how Jira treats created variables.
In automation, variables are stored as text, not numbers. So even if your rule runs successfully, math operations can fail or return empty unless you explicitly handle the type.
To make your Option 1 work without creating field B, you can use the advanced math expression instead of chaining variables:
{{#=}} ({{customfield_A}} + {{lookupIssues.customfield_B.sum}}) / {{customfield_C}} {{/}}
This way, you avoid intermediate variables and ensure Jira evaluates everything as numbers in one step.
In short, instead of storing A+B in a variable, calculate the full expression directly using {{#=}} syntax for reliable results.
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 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)}}*100Does 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.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.