Is there a way to sum the value from two custom formula fields into a separate formula field? I am trying to set up a prospect score in Salesforce based on the customer's lead source. Due to the large number of possible lead sources, I could not put this formula in one field (it exceeded the 5,000 character limit). As a result I split the formula in two and put it in two separate fields. Now, I would like to add them together. However when I add put (Leadscore1__c + Leadscore2__c) in my new field, Salesforce still tells me that my formula is too long. Is there a way to add the values of these two fields together?
Is there a way to sum the value from two custom formula fields into a separate formula field?
You can just create another Formula field and add the other Formula Fields as you would do with any other field.
E.g., if I have two Formula fields as:
I can always create another Formula field say Formula 3 and use the other two fields in my formula editor, something as below.
Formula1__c + Formula2__c
For limits issue, I would imagine that your other two formula fields already are near to the limits and thus when you combine it in a new formula, you run into issues.
You may like to refer to the TIPS FOR REDUCING FORMULA SIZE in this documentation which explains with examples to reduce the formula compile time size.
To correct formula limit errors, move parts of the formula into one or more secondary formula fields, and reference those in your main formula. The secondary fields don’t need to appear on the page layout.
And if everything fails:
If all else fails, use a workflow field update
The document explains on the approaches as how you can reduce either your formula size or can utilize a workflow field update here.
Including one formula into another increases the second one by the size of the first one. Therefore, if the two formulas summed together would be more than 5000 compiled characters, they can't be used in another formula field. The best you could do (besides optimizing your code) would be to use workflow rules or processes/flows to calculate the values into fields. For example, you could make a new number field, then set up a process that sets the value of that field to the sum of the two formula values. You'll want to set this field as read-only so that normal users understand it cannot be modified. You can read more about the situation and resolution in the help topic Formula Field exceeds maximum number of characters (KB 000005456).