Can you do IF Statements in Trello Automations?
Asked by Ashish Dobriyal:

I have 3 custom fields Estimated Time, Actual Time and Priority. I want to do an if statement such as If Actual Time/Estimated Time = 0.5 or less then Set Priority to Low. If Actual Time/Estimated is between 0.5-0.75 then set priority to Medium and if its above 0.75 set to High. Is there a way to do this with automation if there isn't is there a Powerup that can help with it.

Thanks


Answers:
author: Dreamsuite Mike
body: Hi [@Ashish Dobriyal](/t5/user/viewprofilepage/user-id/5349820)

I *think* you can do this best with an additional custom field, for the example below, I called it **Variance**

You will require a few rules:

**Rule 1**

```
when custom field "Estimated Time" is set in a card with custom field "Actual Time" set, set the custom field "Variance" to ({{%Actual TIme}} / {{%Estimated Time}}) *100
```

*Note, I have made the variance figure in % to make it more usable...You can remove the \*100 part if you don't want it as a %?!*

Copy this rule and change the trigger to

```
when custom field "Actual Time" is set in a card with custom field "Estimated Time" set,
```

*This will ensure the rules don't trigger with an empty field...*

<br />

**Rule 2**

This will require copying for the 3 conditions you set. I will write the rule once for the middle one...

```
when custom field "Variance" is set to a number greater than 10 and lower or equal to 75, set the custom field "Priority" to Medium
```

comments: author: Ashish Dobriyal
body: This works perfectly. Thanks.


author: MC
body: Ashish, does "When" still count against your monthly automation count even when it doesn't satisfy the rule? For example...

```
when custom field "Variance" is set to a number greater than 10 and lower or equal to 75, set the custom field "Priority" to Medium??
```

So if "Variance" number is say 100, then it won't automate correct? Therefore, it won't run and count against your Monthly automation count?


author: Dreamsuite Mike
body: Hi [@MC](/t5/user/viewprofilepage/user-id/5470650)

You are correct, there is no reason for that automation to trigger...


author: Hannah Humbert - Simpla Workflows
body: [@Ashish Dobriyal](/t5/user/viewprofilepage/user-id/5349820) it is possible to have your trigger say *"when custom field Actual Time is set to a number lower or equal to 0.5".*Is that what you want? Or are you looking to have estimated and actual time combined somehow in the same rule?

comments: author: Ashish Dobriyal
body: [@Hannah Humbert - Simpla Workflows](/t5/user/viewprofilepage/user-id/2109993) you won't be able to do it like that. Actual Time and Estimated Time are in Days so it would be like for example Actual Time is 4 and Estimated Time is 10 so 4/10 is 0.4 so it should be set to low priority.


author: Hannah Humbert - Simpla Workflows
body: Right, I see, so you're basically wanting to say:  

*"when the "Actual Time" field is set, divide by the "Estimated Time", and if value is 0.5 or less then Set Priority to Low, ... etc."* Did I get that right?   

I'm not sure it's possible to accomplish this all within one rule, however. The first thing that comes to my mind is to create another numerical field to host this calculated value, then create a separate automation to calculate the two fields first (see [custom field arithmetic](https://support.atlassian.com/trello/docs/working-with-custom-fields/)). Then once your value is populated in this field, you can use this as your trigger to set the priority.


author: Ashish Dobriyal
body: Yes, that's what I want it to do. I'll check out the Custom Field Arithmetic. Thanks