2

I have a requirement :

1)If Commercial_Vs_Government__c ,"Government" AND Region__c = 'North America' should be only "Public Sector".

2)Country is : CA then value will be CA.

3)when Commercial_Vs_Government__c is not equals to Government If state is :ME:VT:NH ...............value will be UE

4)when Commercial_Vs_Government__cis not equals to Government If state is :AK:WA:OR ......... Value will be UW

5)if Region is LA then value is LA.

Here Commercial_Vs_Government__c is a picklist ,Region is a formula field . I get an Error as

ERROR : Complied formula is too big to execute 6050 .Max size is 5000 chars

I tried the formulae as :

 IF(ISPICKVAL( Commercial_Vs_Government__c ,"Government"),"Public Sector",

IF(CONTAINS("CA",BillingCountry),"CA",

IF(AND(NOT(ISPICKVAL(Commercial_Vs_Government__c,"Government")),
OR(
BillingState= "ME",
BillingState= "VT",
.
.
.
.
.
.
.
.


)), "UE",

IF(AND(NOT(ISPICKVAL(Commercial_Vs_Government__c,"Government")),
OR(
BillingState= "AK",
BillingState= "WA",
BillingState= "OR",
.
.
.
.
.
.
.'



)), "UW",


IF(AND(CONTAINS("PE:VE:..................................................................................................................................................................,BillingCountry),(Region__c="LA")),"LA",

"Undefined")))))

Any help very much appreciated.

  • Instead of long IF chains you can use CONTAINS method -- help.salesforce.com/apex/…. If formula is still big -- divide that by two fields, and it would not hit the limitations – kurunve Feb 1 '16 at 7:54
3

Case statement is more appropriate here. It prevents repeating the fieldname over and over again. As an example:

CASE(BillingState,

"ME", "UE",
"VT", "UE",
"AK", "UW",
"WA", "UW",

"None")

Check Formula Operators and Functions in Salesforce Help for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.