+ Start a Discussion
Kyle Deweerdt 6Kyle Deweerdt 6 

Shortening CASE function


I am looking for some help shortening this case function.  I am trying to pull over a field that has every lead source channel tracked in it's values and I need to create this field for grouping them into their various marketing groups.  There are a few explicit terms that are spelled out in the case function, but then I need an if statement to say "IF CONTAINS( the category has a "." in it (meaning it is a website url containing .com, .org) then list it in the group "Ref" ) AND IF CONTAINS( different sources that all start with "Organic Something" and I need those all to be group into Organic), Else the Category is Offline.

My error is that the function is too big to execute (28,242 characters). Maximum size is 5,000 characters. I am unsure how this is possible because this is the most condensed version of the function I could manage.  

Any help would be lovely!

CASE( RT_Category__c, "MailChimp", "Email", "Vertical Response", "Email", "Google AdWords", "Paid", "ICIMS", "Paid", "LinkedIn Paid", "Paid", "Facebook", "Social", "LinkedIn", "Social", "Web Direct", "Web", IF(CONTAINS(RT_Category__c, "Organic"), "Organic", IF(CONTAINS(RT_Category__c, "."), "Referral", "Offline")))
What is data type of RT_Category__c field? normally if you are using Formula field inside formula then it character count for both the fields.

PS: if this answers your question then hit Like and mark it as solution!
Kyle Deweerdt 6Kyle Deweerdt 6
It is a very long formula field, so that make sense.  Is there anyway to shorten those? Or redirect it through a different field so it counts a smaller formula?
Shannon HaleShannon Hale
The number of characters you've typed in your formula is not the same as the compile size.

If RT_Category__c is a formula field (which is probably the culprit), check out the Tips for Reducing Formula Size (https://help.salesforce.com/help/pdfs/en/salesforce_formula_size_tipsheet.pdf) tip sheet from Salesforce Docs do what you can to reduce the compile size. If that fails, and you're using Enterprise Edition or higher, you can use a workflow field update to store the value of RT_Category__c in a field and then use that field value in your formula. Again, instructions for this are in the Tips for Reducing Formula Size tip sheet.