0

I am creating this checkbox formula. Criteria is to check the box if:

  • Date Last Project Closed = Last 24 months and Open Projects = 0
  • or Date of Last Won Deal = 12 months and Open Projects = 0

This is what I got, but I keep getting a Syntax Error. Missing ')'

OR(
    ADDMONTHS(Date_Last_Project_Closed__c , 24) < TODAY(),    
    (Open_Projects__c) = 0) || 
    (ADDMONTHS(Date_of_last_won_deal__c , 12) < TODAY(),
                    (Open_Projects__c) = 0)
                )

Please help, I cannot figure out where is the missing ')'. Thanks!

enter image description here

1
  • 1
    Others will answer, but I would advise not mixing OR AND || inside one formula. I recommended sticking with one or the other, as it can make more complex formulae, which are already confusing, even more confusing.
    – Moonpie
    Nov 16, 2021 at 14:30

2 Answers 2

0

Yes, You have added one extra curly brases in last, Could you please try as follows,

(OR (ADDMONTHS(Date_Last_Project_Closed__c , 24) < TODAY(), ADDMONTHS(Date_of_last_won_deal__c , 12) < TODAY()) && Open_Projects__c = 0)

Please let me know if it helps.

1

Being disciplined and consistently formatting your formula can make it much easier to see these types of issues. In a nutshell, you should indent formulas the same as if it were code (I prefer indenting 4 spaces. Two spaces would be the minimum I'd tolerate).

OR(
    ADDMONTHS(Date_Last_Project_Closed__c , 24) < TODAY(),    
    (Open_Projects__c) = 0
) 
|| 
(
    ADDMONTHS(Date_of_last_won_deal__c , 12) < TODAY(),
    (Open_Projects__c) = 0
)
)

It should be very clear now that, despite what the error message says, you have an extra closing parenthesis at the end of your formula.

With that out of the way, your formula is also incorrect (it is not the same as what you have laid out in your requirements). Let's say that:

  • "Date last project closed within the past 24 months" is A
  • "Date of last won deal within the past 12 months" is B
  • "Open projects is 0" is C

What you've currently written is:
(A || C) || (B, C)
The (B, C) part is also syntactically incorrect

What you say you want in your question is:
(A && C) || (B && C)

It's possible to simplify that using some basic Boolean Algebra knowledge to:
(A || B) && C or AND( OR (A, B), C)

It's also good practice to not mix AND() and OR() together with && and ||. Either one is valid, but you should choose one and stick with it. Being undisciplined and inconsistent is a sign of a bad programmer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .