I cannot get a simple substraction between Custom Fields value to work
Asked by Xavier Lecomte:

Hello

I need a field to be populated with the number of month to go till the end of the year.

His number will be based on a custom Start Date. In a separate question Ludo has helps me parsing the Month number from a Custom Start Date Field.

Now I have this "Month Number" parsed I want to do :

"# Months to go" = "13" minus "Month Number"

I don't understand why the following syntax does not work :

when custom field "Probable Start Date" is set to a date, set custom field "PROB MONTH" to "{{%Probable Start Date}\~MM}", and set custom field "YTG Impact" to "{{%FY+1}} - {{%Prob Month})"

All custom fields below are number (except date)

"YTD +1" being set to "13"

"Probable Start date" being set to "April, 15, 2020"

"Prob Month" is correctly evaluated as "4"

but "YTG Impact" is incorrectly set to "13" when I expect 13 - 4 = "9"

I have also tried :

set custom field "YTG Impact" to "13 - {{%Prob Month})"

same result the set always consider only the first term of the operation


Answers:
author: Iain Dooley
body: [@Xavier Lecomte](/t5/user/viewprofilepage/user-id/1188423) this works for me:

when custom field "Start Date" is set to a date, set custom field "Prob Month" to "{{%Start Date}\~MM}", and set custom field "YTG Impact" to "{{%FY+1}} - {{%Prob Month}}"

I think your only problem is that you have included a close parenthesis instead of a closing curly brace, that is this:

when custom field "Probable Start Date" is set to a date, set custom field "PROB MONTH" to "{{%Probable Start Date}\~MM}", and set custom field "YTG Impact" to "{{%FY+1}} - {{%Prob Month})" \<---- note the parenthesis here

should be this:

when custom field "Probable Start Date" is set to a date, set custom field "PROB MONTH" to "{{%Probable Start Date}\~MM}", and set custom field "YTG Impact" to "{{%FY+1}} - {{%Prob Month}}" \<---- note the curly brace here rather than the close parenthesis

comments: author: Xavier Lecomte
body: Hey Iain

Thank you

Below my syntax and that does not work :

when custom field "Probable Start Date" is set to a date, set custom field "PROB MONTH" to "{{%Probable Start Date}\~MM}", and set custom field "YTG Impact" to "13-{{%Prob Month}}"

I think I will go to the support but wanted to thank you


author: Ludo
body: Hi

There is probably a syntax error.

Try this :

{{%FY}+1 - {%Prob Month}}

or {13 - {%Prob Month}}

or 13-({{%Prob Month}})

or ({{%FY}} - {{%Prob Month}})+1

comments: author: Xavier Lecomte
body: Thank you for the attempt. Unfortunately none of the above gives the expected result. Have you ever seen the arithmetic on Number Custom Field Variables working?


author: Ludo
body: Not tested. But visibly it is possible. See this :

<https://help.trello.com/article/1161-custom-field-arithmetic>

<https://help.trello.com/article/1159-arithmetic-in-date-variables>

[@Xavier Lecomte](/t5/user/viewprofilepage/user-id/1188423)

I just have tested this rules, and it works for me

```
when custom field "Date" is set, set custom field "n1" to "{{%Date}~MM}", and set custom field "n2" to "{{%n1}}+3"
```

```
when custom field "Date" is set, set custom field "n1" to "{{%Date}~MM}", and set custom field "n3" to "{{%n1}}+{{%n2}}+3"
```


author: Xavier Lecomte
body: Hey Ludo

Thank you

Below my syntax and that does not work :

when custom field "Probable Start Date" is set to a date, set custom field "PROB MONTH" to "{{%Probable Start Date}\~MM}", and set custom field "YTG Impact" to "13-{{%Prob Month}}"

I think I will go to the support but wanted to thank you


Tags: butler

calculation

custom-field

variable