I have an automation that creates a percentage by dividing one value by the other. Right now, I'm multiplying that by 100 to get a "Percentage"
{{#=}}({{issue.Story point estimate}} / {{issue.Story Points}}) * 100 {{/}}
...this works, but the result is somewhat undesierable as it displayes as "33.333"
I would like it to display as a simple percentage, preferably "33.3%"
I see there is a smart value math function documented ".asPercentage".... But I can't figure out how to implement it.
What I've tried
{{#=}}({{issue.Story point estimate}} / {{issue.Story Points}}).asPercentage {{/}}
{{#=}}{{issue.Story point estimate}} / {{issue.Story Points}}).asPercentage {{/}}
{{#=}}({{issue.Story point estimate}} / {{issue.Story Points}}) * 100 {{/}}.asPercentage
I've also tried to do it in 2 different tasks. First the math, then a second task to do
{{issue.percentDone.asPercentage}} - this also doesn't work.
I don't know what else to try.
Thank you for your time.
You cannot combine the math expression and function format like that. Instead you could try this: {{issue.Story point estimate.divide(issue.Story Points).asPercentage}}
If you want better control on the display digits, please also take a look at format()
Of note, and a hypothesis: I see you are using both Story point estimate and Story Points, which are the two different fields used for team-managed and company-managed projects, respectively. These may not be intended to both contain values. At some point Atlassian may realize the error of their design choice and "fix the glitch", so take care in using both fields.
Kind regards,
Bill
Thank you for the reply Bill.
Your suggestion for the .asPercentage didn't work. But it did change the error message in the log, it's now saying it "could not convert the field value to a number". I'm guessing this is because "PercentDone" is a numeric field and the percent symbol the .asPercentage is putting into it is technically alphanumeric? Any ideas how to get around this.
As to your comment about my usage of Story points. What I'm doing is using the Story Points as a field to judge how many Story points the task is. The Story point estimate is the developers estimate as to how may of those story points they have completed. The math then provides a Percent Done for the task itself. I could not figure a different way to do this, but if there is a way, I'd love to know.
Thank you again for the reply.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would you please post images of your complete rule, including details of the variables or math sections? That may provide some context for that error message.
As for the field errors, if you are trying math on a text (string) field, it can help to add asNumber before doing the math.
For example, if you want to keep that percentage value as number (without the symbol) you could strip it off with .remove("%") before setting the value to the field:
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.
Yup, as I suggested the result of asPercentage is text, so to set it to the PercentDone numeric field you will need:
{{issue.Story point estimate.divide(issue.Story Points).asPercentage.remove("%").asNumber}}
Or...you could multiple and round to get an integer value:
{{issue.Story point estimate.divide(issue.Story Points).multiply(100).round}}
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.