How can add I get my existing calculation to produce a rounded percentage all in one rule?

Mireya Cintora
Contributor
July 13, 2024

Objective: I have an existing rule that produces a decimal proportion, BUT I need it to produce the percentage and round it to the nearest whole number. This is my current rule: 

Screenshot 2024-07-13 at 10.47.12 AM.png

Attempts:

I tried changing the smart value to this {{issue.OrigAllowed.format(".##")}} just to round it but it did not work. So I did not even attempt to covering it to a percentage. Which I don't know if I can even do that or would that have to be a separate rule?

 

Screenshot 2024-07-13 at 10.41.54 AM.png

1 answer

1 accepted

3 votes
Answer accepted
Tim Kopperud
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2024

Hi @Mireya Cintora, if I understand your question correctly you might try something like shown in this formula:

image.png

Which gives this result:

image.png

So, for your rule you need to apply smart values for your custom fields into the ROUND() function, and further define the correct percentage formula. Something like this might work:

{{#=}}ROUND({{customfield_10455}} / {{customfield_10421}} * 100,0){{/}}

The zero marked in yellow below indicates the precission, i.e. how many decimals to apply to the result.

image.png

You don't need to create a varibale for this, apply to your code directly into the And: Edit issue fields step and set "Original Allowed".

The ROUND() functioin is described on this page Jira smart values - math expressions | Automation for Jira Cloud and Data Center | Atlassian Documentation

TimK

Mireya Cintora
Contributor
July 14, 2024

Oh my goodness thank you! It worked perfectly, last question how can i then make it produce the % symbol?

 

If anyone else is wondering this is what the automation looks like: 

Screenshot 2024-07-14 at 4.13.07 PM.png

Tim Kopperud
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2024

Hi @Mireya Cintora, great it worked for you. And thanks for accepting the answer.

To add the % at the end, try something like this:

image.png

Which will give this result

image.png

TimK

Mireya Cintora
Contributor
July 15, 2024

@Tim Kopperud 

Unfortunately it did not work. I think based off the audit log its because the field is a number field and the percentage symbol is not a number? 

Screenshot 2024-07-15 075659.pngScreenshot 2024-07-15 075636.png

Tim Kopperud
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2024

Hi @Mireya Cintora, yes that is right. You cannot add any non-numbers to a number field. You might add something in the description for the field, that informs about the result in percentage. 

You might use a text field for this instead of number field even if it contains a number value. Though this is not working prefect if you need to sort by this field in reports etc. A text field uses text sort therefore it regards 10 as before 2. In number sort 2 is before 10 etc. 

TimK

 

Suggest an answer

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

Atlassian Community Events