function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vinitha SubramanyaVinitha Subramanya 

Syntax error in nested IF formula

The below IF statement is giving a syntax error "Missing )". Not sure which ) is missing. Thisis to calculate the discount amount based on the contract term.

IF( Opportunity_Name__r.Committed_Term_Months__c = 12,(((149 - Sales_Price__c)* Users__c)*12),
 IF( Opportunity_Name__r.Committed_Term_Months__c = 24, (((149 -Sales_Price__c)* Users__c)*24),
  IF( Opportunity_Name__r.Committed_Term_Months__c = 48, (((149 - Sales_Price__c)* Users__c)*48), (((149 - Sales_Price__c)* Users__c)*36),
0)))
Best Answer chosen by Vinitha Subramanya
Edna Brown 8Edna Brown 8
Hello,

The issue in the IF statement lies in the number of closing parentheses ) used. There is one closing parenthesis missing in the last part of the statement. Here's the corrected version:

 IF( Opportunity_Name__r.Committed_Term_Months__c = 24, (((149 - Sales_Price__c) * Users__c) * 24),
  IF( Opportunity_Name__r.Committed_Term_Months__c = 48, (((149 - Sales_Price__c) * Users__c) * 48),
   (((149 - Sales_Price__c) * Users__c) * 36)
  )
 )
)

In this corrected version, the missing closing parenthesis was added after the expression (((149 - Sales_Price__c) * Users__c) * 36).
Mary Kay (http://Mary Kay In Touch Login)
Regards,
Edna

All Answers

Edna Brown 8Edna Brown 8
Hello,

The issue in the IF statement lies in the number of closing parentheses ) used. There is one closing parenthesis missing in the last part of the statement. Here's the corrected version:

 IF( Opportunity_Name__r.Committed_Term_Months__c = 24, (((149 - Sales_Price__c) * Users__c) * 24),
  IF( Opportunity_Name__r.Committed_Term_Months__c = 48, (((149 - Sales_Price__c) * Users__c) * 48),
   (((149 - Sales_Price__c) * Users__c) * 36)
  )
 )
)

In this corrected version, the missing closing parenthesis was added after the expression (((149 - Sales_Price__c) * Users__c) * 36).
Mary Kay (http://Mary Kay In Touch Login)
Regards,
Edna
This was selected as the best answer
aanojas lanceraanojas lancer
To match the starting parentheses of the nested IF statements, place a closing parenthesis before the last zero (0). The structure of your formula remained unchanged, with the exception of the missing parenthesis. If you have any additional requirements or if any sections of the formula need to be adjusted, please let us know.
Arun Kumar 1141Arun Kumar 1141
Hi Vinitha,

In the provided formula, it seems that there is a missing closing parenthesis at the end of the formula. Here's the corrected version of the formula:

IF(Opportunity_Name__r.Committed_Term_Months__c = 12, (((149 - Sales_Price__c) * Users__c) * 12),
 IF(Opportunity_Name__r.Committed_Term_Months__c = 24, (((149 - Sales_Price__c) * Users__c) * 24),
  IF(Opportunity_Name__r.Committed_Term_Months__c = 48, (((149 - Sales_Price__c) * Users__c) * 48), (((149 - Sales_Price__c) * Users__c)))))

So, add a closing parenthesis at the end of the formula to close the last nested IF statement.

If this helps you please mark it as a best answer,
thanks!
Vinitha SubramanyaVinitha Subramanya
Thank you all for stepping in. I went with Mary Kay's suggestion and it worked. Thanks again!