How can add I get my existing calculation to produce a rounded percentage all in one rule?
Asked by Mireya Cintora:

**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](/t5/image/serverpage/image-id/335461iC68A9875A3966452/image-size/large?v=v2&px=999 "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](/t5/image/serverpage/image-id/335462i4743DE7D7B794C8A/image-size/large?v=v2&px=999 "Screenshot 2024-07-13 at 10.41.54?AM.png")


Answers:
author: Tim Kopperud
body: Hi [@Mireya Cintora](/t5/user/viewprofilepage/user-id/5526385), if I understand your question correctly you might try something like shown in this formula:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/335482i121C98DB654E45DE/image-size/large?v=v2&px=999 "image.png")

Which gives this result:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/335483i2285960F76F1FA3F/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/335484i1B279CEC152EA900/image-size/large?v=v2&px=999 "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](https://confluence.atlassian.com/automation/jira-smart-values-math-expressions-993924866.html).

TimK

comments: author: Mireya Cintora
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/335509i9B53C25A433C2C43/image-size/large?v=v2&px=999 "Screenshot 2024-07-14 at 4.13.07?PM.png")


author: Tim Kopperud
body: Hi [@Mireya Cintora](/t5/user/viewprofilepage/user-id/5526385), great it worked for you. And thanks for accepting the answer.

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

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/335543i003CB02F86BC7770/image-size/large?v=v2&px=999 "image.png")

Which will give this result

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/335545iBA39D5F02186A553/image-size/large?v=v2&px=999 "image.png")

TimK


author: Mireya Cintora
body: [@Tim Kopperud](/t5/user/viewprofilepage/user-id/492874)

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.png](https://community.atlassian.com/t5/image/serverpage/image-id/335686i037F94B64A1092B9/image-size/large?v=v2&px=999 "Screenshot 2024-07-15 075659.png")![Screenshot 2024-07-15 075636.png](https://community.atlassian.com/t5/image/serverpage/image-id/335687i2C89020E9791CB75/image-size/large?v=v2&px=999 "Screenshot 2024-07-15 075636.png")


author: Tim Kopperud
body: Hi [@Mireya Cintora](/t5/user/viewprofilepage/user-id/5526385), 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


Tags: cloud

jira-service-management

jira-service-management-cloud