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

syntax on how to check automation  variable's value to zero

Lopes_ Bonnie
Contributor
March 5, 2025

Looking for syntax on how to check automation  variable's value to zero.

I later divide by this variable varTotalCountSmart, so need to add a condition before the math function to not execute the create variable varEpicCompletion if varTotalCountSmart is equal to 0

 

variable.PNG

calculation

epic completion.PNG

 

varTotalCountSmart

 

varTotalCountSmart

1 answer

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2025 edited

Hi @Lopes_ Bonnie 

Without seeing your entire rule, what do you want to happen when the total count is 0?

UPDATED: please see answer in a later post to handle when it is unknown if numerator equals 0.

Let's assume you want the varEpicCompletion to be 0 also.

There are several ways to handle this, and the simplest is to use an inline condition to substitute a value when it is 0, such as 1.  This could be done in either variable because if the total count is 0, the done count is also likely 0; thus 0 / 1 = 0.

  • action: create variable
    • name: varEpicCompletion
    • value:
{{#=}} FLOOR( {{varDoneCount}} / {{if(varTotalCount.asNumber.gt(0), varTotalCount, 1)}} * 100) {{/}}

 

Kind regards,
Bill

Lopes_ Bonnie
Contributor
March 6, 2025 edited

@Bill Sheboy ,

Thank you so much for this your analysis was spot on.  however, the new formula, did not produce expected results when:

input:

varTotalCount = 30

varDoneCount = 5

result: Percent complete is: 500, Done Count: 5, Child Issue count: 30

expected result : Percent complete is: 16, Done Count: 5, Child Issue count: 30

 

it  doesn't appear this is working quite right

if(varTotalCount.asNumber.gt(0), varTotalCount, 1)

                                                      true                 false

Seems in the first scenario I still got a false, so 5/1 = 5*100 = 500

 

 

for the scenario you were addressing the results work fine,  it ran successfully and didn't give me the divide by 0 error

input:

varTotalCount = 0

varDoneCount = 0

Percent complete is: 0, Done Count: 0, Child Issue count: 0

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 7, 2025

Sorry, I should have read my own post more clearly :^)

This one works for both cases, putting the default value of 0 before the long-format of conditional expression.

{{#=}} FLOOR ( 0{{#if(varTotalCount.asNumber.gt(0))}}{{varDoneCount}}/{{varTotalCount}} * 100{{/}} ){{/}}

 

More information...

My earlier assumption was varDoneCount will be 0 when varTotalCount is 0.  To handle errors where that assumption is not valid the new expression wraps all the math inside the logical test.

And, the inline conditional version will not work as it assumes the values for "true" and "false" are text, and so cannot be fully evaluated as numbers until exiting the condition block / parentheses. 

Lopes_ Bonnie
Contributor
yesterday at 10:52 AM

@Bill Sheboy 

You were right from the beginning, your first answer was correct and your assumption was correct.  Please keep both formulas in the final answer acceptance, as I may need the second for another problem in the future, so I wouldn't want to lose it.

The problem was the variable was actually called varTotalCountSmart  not varTotalCount.

stupid me missed that, when I just pasted in the expression.

Thank you so much again for all your assistance.  You have been a life saver in getting this correct.

We can accept your first answer or your second, both work

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events