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,557,698
Community Members
 
Community Events
184
Community Groups

Automation and formatting to 2 decimal places

Hi

I want to calculate the amount of time between certain workflow statuses and for the result to be in hours with 2 decimal places.

For testing I am taking the minutes since creation, dividing by 60 and putting this in a variable called hours:

{{#=}}{{now.diff(issue.created).minutes.abs}} / 60{{/}}

The variable is fine and prints to the log as {{hours}}

But I can't get the formatting to work. I tried {{hours.format("###.##")}}  following the answer in this question but that produces no output at all. Any tips welcome, thanks!

 

2 answers

1 accepted

0 votes
Answer accepted
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.
Apr 27, 2021 • edited

Hi @Julia Foden 

I was able to do this with ROUND() so you could try:

{{#=}}ROUND({{now.diff(issue.created).minutes.abs}} / 60, 2){{/}}

Best regards,

Bill

That's perfect Bill, thankyou very much!

Like Bill Sheboy likes this
0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 27, 2021

Hi Julia,

Maybe try to put the word issue in front:

{{issue.hours.format("###.##")}}

I also tried this solution, but cannot get a custom created variable to format to display 2 decimals

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

Hi @Karen Kelly  - did you see Bill's response above? Can you share what you have that is not working? 

Hello @John Funk ,

 

Yes, the rounding works perfectly but if I want to display 2 decimals on e.g. 100 like 100.00 I can get t right using a custom field format e.g.

{{issue.customfield_xxx.format("##.00")}}

But not on my custom variable {{total}}

tried everything {{total.format("##.00")}} doesn't work and {{issue.total.format("##.00")}} neither

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

ah, it might be something related to how a variable handles values - meaning it might not be natively using it as a number. But that's beyond me. 

Maybe @Bill Sheboy can weigh in. 

Like Karen Kelly likes this
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.
May 10, 2023

Hi @Karen Kelly 

Are you trying to change the stored value in the Total field or the output in some message, email, etc.?

If you are trying to change the stored value of Total, what you describe will only work if you have a text field.  If it is numeric, Jira will most likely truncate any trailing, zero digits.

Or...is this a created variable?  Sorry as I was unclear on you scenario.

Kind regards,
Bill

hello @Bill Sheboy ,

I created this custom variable as part of my automation, it is the sum of a few fields, I just want the output to how with 2 decimals instead of truncated. Referencing it in the summary of the issue

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.
May 11, 2023

Thanks for clarifying, Karen.

What I think is happening is created variables are always text type (at this time...) and so your variable needs to be converted to a number for the format() function to work.  (Format can also work with date/time types...which are really number behind the scenes.)

Please try this:

{{total.asNumber.format("##.00")}} 
Like Karen Kelly likes this

Thank you! This is the perfect solution! I appreciate the feedback

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events