I have following command to calculate variable {{KMProgress}} as a percentage of count of done items divided by the total count of items: ({{KMDoneCount}}/({{KMTotalCount}})*100)
Both of the variables are {{lookupIssues.size|0}} of different JQL's - first returning 1 done item and second returning 10 items in total
When I run the automation and call {{KMProgress}} to be send by email this is the result I get: (1/(10)*100)
Can someone explain/help why it is not counting/returning that progress is 10% but instead returning a text?
Thanx
For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!
Until we see those...
Created variables are text, not other types, like numbers. To use a created variable in a math expression it usually must be converted with asNumber. For example:
{{KMDoneCount.asNumber}}
What you saw was the text values concatenated together as they were not numbers.
Next, there are two formats for math expressions: inline and the longer format: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/
What you plan to do with the result may help decide which format to use. For example, the inline format of your formula could be this:
{{KMDoneCount.asNumber.divide(KMTotalCount.asNumber).multiply(100)}}
This will not handle empty fields / variables, but that should not be needed as you are using the default value of 0 with your lookup expression: {{lookupIssues.size|0}}
Additional tip: as you appear to trying to produce a percentage value, consider adding the asPercentage function or using floor or ceil (i.e., ceiling) to limit the result digits.
Kind regards,
Bill
Hi @Bill Sheboy
Sure, here is the whole automation rule picture:
I have used suggested command below, this time the result was 0
{{KMDoneCount.asNumber.divide(KMTotalCount.asNumber).multiply(100)}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please show the details of the actions to set the values of the variables.
Please post an image of the audit log showing the rule execution. That will indicate if there were problems with any of the rule steps.
Does your rule trigger include any JQL? For this type of rule, I would not expect it to have any.
Have you tried writing the variables to the audit log to confirm they have values, as you expected?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Variable KMTotalCount:
Variable KM DoneCount:
Variable KMProgress:
Thank just calling it all in the mail:
According to info in audit log, it seems to me that I am pulling the issues I want to pull
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for that information.
Did you try writing each created variable to the audit log to confirm their values?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy I tried to investigate audit log, this is the only thing I see there:
And these are the items I am looking for - so not sure why I am not getting the calculation correctly.
Other interesting thing is that if I swap the formula it returns the number it is supposed to return: {{KMTotalCount.asNumber.divide(KMDoneCount.asNumber)}}, the other way around I always get 0.
Any ideas why it happens when I am dividing smaller number with higher it does not work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This uncertainty is why I asked for an audit logging of each individual created variable:
{{KMTotalCount}}
{{KMDoneCount}}
etc.
That would first confirm the counts (and thus the lookups and JQL) worked as you expected, before using them in math operations.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Really no clue what can be the issue so taking step back.
The need is to send report every week showing the "progress" on Initiative (backlog hierarchy is Initiative - Epic - Story).
I would like to show the progress by taking the done child items under the initiative (epics and stories) and divide them by total number of items under initiatives (epics and stories). Final number multiply by 100 to get the result in %.
How would you approach that automation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As you want to count issues, from the initiative and downward, I believe you on the correct path with the lookup issues usage. And creating each piece incrementally in variables is a good way to validate what you are doing.
It is possible to perform this calculation in a single step, using list filtering, but that is difficult to maintain.
Instead let's stick with your approach and create a new test rule to diagnose this:
Now pause and test that rule by running it manually from the top-right of the editor ... > Run Rule and look at the audit log.
Do the results match what you expect for the counts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, once I redefined the variables it it started to return numbers instead of text.
Thank you very much for your help!
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.
It should be ((1/10)*100)
For mathematical calculations just follow the below article
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Even with updated it still returns only text (Current progress is ((1/10)*100))
What I need it to return is number (Current progress is 10)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure how the variables were set in the automation to get the count, log them for further troubleshooting.
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.