Hi, not able to get a correct answer using smart values

Verma_ Shivam
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 3, 2024

i have created a rule to create schedule variance in Jira automation, the rule is executing perfectly but the answer is still 0.

i am using this formula, 

 

{{issue.customfield_12425.diff(issue.customfield_11025).days.divide(issue.customfield_11025.diff(issue.customfield_11024).days)}}

 

please let me know where i am wrong.

2 answers

1 vote
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 3, 2024

Hello @Verma_ Shivam 

Welcome to the Atlassian community.

What are the field types of each of the custom fields in that formula?

I recommend that you use that the Log action in the rule to:

  1. Print each of the custom field values to the rule Audit Log
  2. Print portions of the calculation, such as the result of the first diff() function, and the result of the second diff() function

Printing the values with the Log action will enable you to review the values to see if they match your expectations.

If that doesn't reveal the problem to you then please provide the following:

  1. Screen images showing the entire rule
  2. Details of the step where you are using the formula
  3. The rule Audit Log output.
Verma_ Shivam
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 4, 2024

Hi Trudy,

All these custom fields are date picker field, i am trying to get value for (Actual End Date - Planned End Date)/(Planned End Date - Planned Start Date)

 

i am trying to capture the output of this formula in another custom field "Schedule Variance" which is a number field.

Screenshot 2024-12-04 133217.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 4, 2024

Thank you for that additional information.

I recommend that you use the Log action in the rule to:

  1. Print each of the custom field values to the rule Audit Log
  2. Print portions of the calculation, such as the result of the first diff() function, and the result of the second diff() function

Printing the values with the Log action will enable you to review the values to see if they match your expectations.

If that doesn't reveal the problem to you then please provide the following:

  1. Screen images showing the entire rule
  2. Details of the step where you are using the formula
  3. The rule Audit Log output.
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.
December 4, 2024

Hi @Verma_ Shivam -- Welcome to the Atlassian Community!

As Trudy describes, context is important for automation rule questions, so please include images of your complete rule, the audit log details, and explain the problem you are trying to solve. 

For such types of rules, it also helps to use the Log action to write intermediate results and smart values to the audit to check the values are what is expected.

 

Until we see that information...

You describe "the answer is still 0", and that is certainly possible for the expression you show.

  • When using the date / time diff() function, the results is always an integer value
  • The inline-line type of smart value, math expressions preserve the type usually
  • When you diff().days that would be an integer
  • Finally, when the division occurs, that would also be an integer, probably truncating down to 0

To get a fractional value, a math expression may be used.  For example:

{{#=}} {{issue.customfield_12425.diff(issue.customfield_11025).days}} / {{issue.customfield_11025.diff(issue.customfield_11024).days}} {{/}}

If you wanted that to a specific number of significant digits, you could add the ROUND() function, for example to 2 significant digits:

{{#=}} ROUND( {{issue.customfield_12425.diff(issue.customfield_11025).days}} / {{issue.customfield_11025.diff(issue.customfield_11024).days}}, 2) {{/}}

 

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events