Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
6 years, 6 months ago
formula function has a compiled cost that contributes towards the hard 5000 compiled character formula limit.
What are the current compiled costs associated with each formula function?
Nov 13, 2016 at 21:23
Daniel Ballinger Daniel Ballinger
101k 38 38 gold badges 259 259 silver badges 578 578 bronze badges
There are a lot of functions to check, so building a complete list will take a bit of work. I've made this a community post so others can contribute if they like.
Salesforce changes the implementation of functions over time, so the exact costs can change.
Determining the compiled formula cost currently relies of comparing the compiled size of a formula that includes the function with one that doesn't. There may be other factors that affect the compiled size of a function. For instance, some functions cost depends on the argument values.
(): 1 each (each pair costs 2)
AND/&&: 7 for two parameters, 6 for each extra parameter
CASE: 27 for minimum 4 parameters, 12 for each extra pair of parameters
In Spring '21 using a picklist field, 84 minimum for 4 parameters, 64 for each extra pair of parameters
NOT, !: 6
OR/||: 6 for two parameters, 5 for each extra parameter
<, >, =: 3
>=, <=, <>: 4
MAX: 12 for two parameters, plus 2 per extra parameter
MIN: 9 for two parameters, plus 2 per extra parameter
MOD: 7, plus length of second parameter
ROUND: 9, plus length of second parameter
BEGINS - 57 + length of length parameter
BR - 18
CASESAFEID ~ 2073. Depends on Reference & Object.
CASESAFEID(Foo__c) takes less than
CASESAFEID(Foo__r.Id). Standard Objects seem to take less than custom -
Idea to reduce size CONTAINS - 58 +length of length parameter
FIND - 46
GETSESSIONID - 13
HYPERLINK - Base of 88, increases by 1 for each
IMAGE - Base of 19, increases by 1 for each
ISPICKVAL - ~ 51-53, no cost/optimized out if the test value is not one of the active or inactive picklist values
LEFT - 26+length of length parameter
LEN - 15
LOWER - 37
MID - 38+length of length parameters.
RIGHT - 45+length of length parameter
SUBSTITUTE - 29
TEXT - 42 for Number field, 64 for DateTime field
TRIM - 18
UPPER - 37
VALUE - 23
Some optizations exist in the compiler engine. For example, mathematical operations that do not involve fields are "solved" to their final value. For example,
1+5 compiles to just 1 character, because the result is always 6. Similarly, functions like NULLVALUE use no extra characters if the field is required (e.g.
NULLVALUE(Name,'No Name') uses 12 characters).
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only