Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,464,906
Community Members
 
Community Events
176
Community Groups

Jira automation - how do I make my math expression conditional

I have an automation statement where I am working out % complete and this rolls up to show %complete in the parent Epic.   It all works ok but occassionally, the child issues in the Epics have no Story Points and therefore I get a divide by 0 error.  I've been trying to use IF to make this conditional so that if varTotalStoryPoints.asNumber is zero, I just assign 0 to the variable and avoid the divide by zero error but I just cant get the syntax right - can anybody help please ?

{{#=}} {{varStoryPointsComplete.asNumber}} / {{varTotalStoryPoints.asNumber}} * 100 {{/}}

3 answers

Hi @Ian Rees

Try using the smart value math expressions - Functions :

{{#=}} IF({{varTotalStoryPoints.asNumber}} > 0,{{varStoryPointsComplete.asNumber}}/{{varTotalStoryPoints.asNumber}}*100,0) {{/}}.

You might want to consider using asPercentage  (also with a locale option) when formatting for display to avoid having to do the * 100.

Hi @Stanley, Rob that's the syntax I've been trying but can't seem to get it right - for instance {{#=}} IF({{varTotalStoryPoints.asNumber}} > 0,{{varStoryPointsComplete.asNumber}}/{{varTotalStoryPoints.asNumber}}*100,0) {{/}}.

 

gives unexpected comma error

This worked for me is stopping the divide by zero error

{{#=}} IF({{varTotalStoryPoints.asNumber.eq(0)}},0,{{varStoryPointsComplete.asNumber}} / {{varTotalStoryPoints.asNumber}} * 100){{/}}

Hi @Ian Rees

Just wrap your "Edit Issue"-Action inside an if-else block with an "Advanced Compare"-Condition which checks whether {{varTotalStoryPoints.asNumber}} is 0. If it is: "Edit Issue"-Action -> Set field to 0, else "Edit Issue"-Action -> Set field to MathExpression.

Final section should look something like this:

Webaufnahme_15-7-2022_15231_demo-jodocus.atlassian.net.jpeg

Note: Change Description to the field you want to edit. First Edit sets the field to 0 - Second edit sets the field to the expression.

 

Hope this helps. Feel free to reach out if there are any problems with this.

 

Greetings

Gideon

0 votes
Gaurav Community Leader Jul 15, 2022

Hello @Ian Rees 

For this automation, the 'If Else' construct would be required. From the available details, I understand that you are storing the Total Story Points and Story Points Complete in variables.

So, when we select the If clause, opt for the 'Advanced compare condition'. The settings should be:

  • First value should be set as 'varTotalStoryPoints.asNumber'
  • The second value should be 0
  • Condition 'equals'

I hope this helps set up the IF condition. Please reach you if you have any follow-up questions.

Kindly accept the answer if this helps.

Regards,

--GG

Suggest an answer

Log in or Sign up to answer