Automation to compare Original Estimate with Time Spent and add specific label
Asked by dei:

I want to create an Automation that sets

1. the label "under-estimated" if the Time Spent is greater than the Original Estimate
2. the label "over-estimated" if the Time Spent is smaller than the Original Estimate

Her are my Screens for Rule 1:  
It seems that my approach is not working.

![Bildschirmfoto 2024-06-23 um 11.37.43.png](/t5/image/serverpage/image-id/331277i7993516FC547C958/image-size/large?v=v2&px=999 "Bildschirmfoto 2024-06-23 um 11.37.43.png")

![Bildschirmfoto 2024-06-23 um 11.37.58.png](/t5/image/serverpage/image-id/331276i4C4CA9A5BEE3BED4/image-size/large?v=v2&px=999 "Bildschirmfoto 2024-06-23 um 11.37.58.png")

![Bildschirmfoto 2024-06-23 um 11.38.25.png](/t5/image/serverpage/image-id/331278i5964BB75F882E3CE/image-size/large?v=v2&px=999 "Bildschirmfoto 2024-06-23 um 11.38.25.png")


Answers:
author: Tommaso Gionfriddo _Teklada_
body: Hi [@dei](/t5/user/viewprofilepage/user-id/4729083) ,

The original estimate field should be accessed via {{issue.timetracking.originalEstimate}}. You can double check this by following [this how-to by Atlassian.](https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/)

There is one more complexity you'll need to consider.

The output of originalEstimate and timeSpent is provided in the period format (1d 2h etc.)  
These strings do not compare well, for example 1d would be smaller than 2h, so you instead need to compare originalEstimate**Seconds** with timeSpend**Seconds**. This will act as you expect.

![Screenshot 2024-06-23 at 15.04.56.png](https://community.atlassian.com/t5/image/serverpage/image-id/331285i9ADB022DAA27F586/image-dimensions/286x257?v=v2 "Screenshot 2024-06-23 at 15.04.56.png")

comments: author: dei
body: Thanks [@Tommaso Gionfriddo _Teklada_](/t5/user/viewprofilepage/user-id/3696717)

You have helped me a lot.  
But I still have to integrate that no over-estimated and under-estimated label is assigned if no effort estimation has taken place.

Also I am not sure if my way works if I have an estimate of 5h. After 4h have been logged, the label over-estimated is applied. If I now log 7h again on the same issue and exceed the estimate, I am not allowed to have both labels in the issue. I'll probably have to tinker with it. But thanks to you, I have already learnt something. Thank you!


author: Tommaso Gionfriddo _Teklada_
body: Hi [@dei](/t5/user/viewprofilepage/user-id/4729083) ,

To not apply a label when no estimation has taken place, I would simply recommend adding a condition that checks that the estimation field contains a value. Please see the screenshot below for an example.

![Screenshot 2024-06-24 at 15.53.04.png](https://community.atlassian.com/t5/image/serverpage/image-id/331436i20A2A50552821EAF/image-size/large?v=v2&px=999 "Screenshot 2024-06-24 at 15.53.04.png")

To ensure only the correct label is applied, when you edit the issue to add the new label you can also remove the old label

To do this

1. Select the ADDREMOVE operation on the label field![Screenshot 2024-06-24 at 15.55.57.png](https://community.atlassian.com/t5/image/serverpage/image-id/331439iC0F96D3AAD942A7B/image-dimensions/211x192?v=v2 "Screenshot 2024-06-24 at 15.55.57.png")
2. Enter "over-estimated" in the Values to add field
3. Enter "under-estimated" in the Values to remove field![Screenshot 2024-06-24 at 15.58.38.png](https://community.atlassian.com/t5/image/serverpage/image-id/331444i5421106E848453E0/image-size/large?v=v2&px=999 "Screenshot 2024-06-24 at 15.58.38.png")

Now when the over-estimated label is added to an issue, if the under-estimated label is already on the issue. it will be removed.  
You can then simply repeat these steps for the under-estimated logic, and you should be good to go.


Tags: automation

cloud

jira-cloud

original-estimate

time-spent