Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How I can use the default formula used in original estimate to show weeks, days and hours

VT Jira September 18, 2024

I have a few custom fields where I have to update the total sum of the subtasks estimates as per some defined percentage. I have used the following formula:

{{#=}} floor({{issue.subtasks.Original estimate.sum.divide(3600).multiply(0.20)}} / 40) + "w " + floor({{issue.subtasks.Original estimate.sum.divide(3600).multiply(0.20)}} % 40 / 8) + "d " + ({{issue.subtasks.Original estimate.sum.divide(3600).multiply(0.20)}} % 40 % 8) + "h" {{/}}

I am getting this error:
Unable to parse expression floor(10 / 40) + "w " + floor(10 % 40 / 8) + "d " + (10 % 40 % 8) + "h" : floor(10 / 40) + "w " + floor(10 % 40 / 8) + "d " + (10 % 40 % 8) + "h"

 

I have also tried using the following:

{{#=}} totalQaHours = {{issue.subtasks.Original estimate.sum.divide(3600).multiply(0.20)}}; weeks = floor(totalQaHours / 40); remainingQaHoursAfterWeeks = totalQaHours % 40; days = floor(remainingQaHoursAfterWeeks / 8); remainingQaHours = remainingQaHoursAfterWeeks % 8; weeks + "w " + days + "d " + remainingQaHours + "h" {{/}}


For this, I am getting the following error:

Unknown operator ; at character position 18: totalPmHours = 14; weeks = floor(totalPmHours / 40); remainingPmHoursAfterWeeks = totalPmHours % 40; days = floor(remainingPmHoursAfterWeeks / 8); remainingPmHours = remainingPmHoursAfterWeeks % 8; weeks + "w " + days + "d " + remainingPmHours + "h"


And then for the final total value, I have used the following expression:


{{#=}} qaTotalHours = {{issue.QA Estimation.split("w").first.trim}} * 40 + {{issue.QA Estimation.split("w").last.split("d").first.trim}} * 8 + {{issue.QA Estimation.split("d").last.split("h").first.trim}}; saTotalHours = {{issue.SA Estimation.split("w").first.trim}} * 40 + {{issue.SA Estimation.split("w").last.split("d").first.trim}} * 8 + {{issue.SA Estimation.split("d").last.split("h").first.trim}}; pmTotalHours = {{issue.PM Estimation.split("w").first.trim}} * 40 + {{issue.PM Estimation.split("w").last.split("d").first.trim}} * 8 + {{issue.PM Estimation.split("d").last.split("h").first.trim}}; totalHours = qaTotalHours + saTotalHours + pmTotalHours; weeks = floor(totalHours / 40); remainingHoursAfterWeeks = totalHours - (weeks * 40); days = floor(remainingHoursAfterWeeks / 8); remainingHours = remainingHoursAfterWeeks - (days * 8); weeks + "w " + days + "d " + remainingHours + "h" {{/}}


Can you please suggest to me here, How I can fix this issue?

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.
September 18, 2024

Hi @VT Jira 

Without reviewing the specific errors you are observing, I suggest pausing to consider:

The Original Estimate or smart value {{issue.timetracking.originalEstimate}} is the human-readable value, containing the units of measure.  For example: 1d 4h.  That value can be difficult to parse as a number in math operations.

The Original Estimate Seconds or smart value {{issue.timetracking.originalEstimateSeconds}} is just the number of seconds, and is likely the one you should use for math operations.

 

Please use the number value originalEstimateSeconds and adjust your calculations before proceeding. 

If you are still encountering challenges, please images of your rule, rule actions, and of the audit log details to provide context for the symptoms.

 

And also...I recommend review the how-to article below as it can help become familiar with names and structure of supported smart values in rules:

https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

Kind regards,
Bill

VT Jira September 18, 2024

Hi @Bill Sheboy 

 

Thank you for your prompt response.

I have implemented a rule to automatically update the original estimates, remaining estimates, and story points of a parent task whenever the original estimate of a field type subtask changes. This calculation is based on the sum of the subtasks' estimates. Previously, this rule functioned as expected, and I was able to successfully update the relevant fields.

However, upon adding custom fields for PM/SA and QA estimations, I encountered the error described in my previous query. These custom fields use the same structure (w, d, h) and update logic as the original estimates.

Attached are screenshots of the rule and rule action for your reference.

rule-setup-1.png
rule-setup-2.png


VT Jira September 19, 2024

Hi @Bill Sheboy ,

I have sorted out above. But now I am getting another issue.

I have used the following syntax for conditional rendering of estimates in custom fields:

{{#if(floor(issue.subtasks."Original estimate".sum.divide(3600).multiply(0.15).divide(40)) > 0)}}
{{floor(issue.subtasks."Original estimate".sum.divide(3600).multiply(0.15).divide(40))}}w
{{/}}
{{#if(floor(issue.subtasks."Original estimate".sum.divide(3600).multiply(0.15).mod(40).divide(8)) > 0)}}
{{floor(issue.subtasks."Original estimate".sum.divide(3600).multiply(0.15).mod(40).divide(8))}}d
{{/}}
{{#if(floor(issue.subtasks."Original estimate".sum.divide(3600).multiply(0.15).mod(8)) > 0)}}
{{floor(issue.subtasks."Original estimate".sum.divide(3600).multiply(0.15).mod(8))}}h
{{/}}

But it is showing values as 0w 2d 3h. 

How I can remove if any value is 0 like 0w should not appear above.
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.
September 19, 2024

You could use the diff() function's prettyPrint format to do this for you automatically: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-difference---

For example, adding any number of seconds to {{now}} and differencing it with the original value:

{{now.diff(now.plusSeconds(some seconds)).prettyPrint}}

In your scenario, "some seconds" would be your adjusted value.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events