You are here:
Operators and Functions in Expression Sets
Formulas in expression sets support logical, comparison, mathematical, and string operators, and functions for dates and numbers.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Unlimited, and Developer Editions for clouds that have Business Rules Engine enabled |
Supported Operators in Expression Sets
Mathematical operators take precedence over comparison and string operators, which take
precedence over logical operators. Within mathematical operators, ^ and % have the highest
precedence, followed by * and /, then + and -. When precedences are equal, operations are performed from
left to right. You can use parentheses, ( ), to
explicitly specify precedence.
| Operator | Description |
|---|---|
|
True if all the joined expressions are true. For example, A AND B returns true if both A and B are
true. |
|
True if one of the joined expressions is true. For example, A AND B returns true if either A or B is
true. |
=
|
Assigns the value of the second expression to the first expression. For
example, A = 2 sets the value of A to
2. |
|
True if the values of the first and second expressions are equal. For example,
2 == 2 returns true. |
|
True if the values of the first and second expressions aren’t equal. For
example, 3 != 2 returns true. |
|
True if the first expression has a greater value than the second. For example,
3 > 2 returns true. |
|
True if the first expression has a greater value than the second or if the
values are equal. For example, both 3 >= 2 and
2 >= 2 return true. |
|
True if the second expression has a greater value than the first. For example,
2 < 3 returns true. |
|
True if the second expression has a greater value than the first or if the
values are equal. For example, both 2 <= 3
and 2 <= 2 return true. |
Is Null
|
True if the value of a resource is null. |
Is Not Null
|
True if the value of a resource isn’t null. |
If |
Returns a given value if true and another value if false.
Make sure your
|
| Operator | Description |
|---|---|
+
|
Adds two numbers. |
|
Subtracts the second number from the first. |
*
|
Multiplies two numbers. |
/
|
Divides the first number by the second. |
%
|
Returns the percentage of the first number specified by the second number. For
example, 50 % 20 returns 10. |
^
|
Returns the power of the first number specified by the second number. For
example, 2 ^ 3 returns 8. |
Supported Functions in Expression Sets
| Function | Description | Example |
|---|---|---|
LISTAVG |
Returns the average of numeric (Number, Currency, Percent) values in a list variable. This function is applicable to context definition tags, which are used as list variables in expression set versions. |
The function returns the average of all the values in the list variable. |
LISTSIZE |
Returns the number of items in a list. This function is applicable to context definition tags, which are used as list variables in expression set versions. |
The function returns the total number of items or records in the ProductName variable. |
LISTSUM |
Returns the sum of numeric (Number, Currency, Percent) values in a list variable. This function is applicable to context definition tags, which are used as list variables in expression set versions. |
The function returns the sum of all the values in the list variable. |
| Function | Description | Example |
|---|---|---|
ADDDAY |
Adds the specified number of days to the specified date and returns the resulting date. |
The function returns |
ADDMONTH |
Adds the specified number of months to the specified date and returns the resulting date. |
The function returns |
ADDYEAR |
Adds the specified number of years to the specified date and returns the resulting date. |
The function returns |
AGE |
Returns the age for the specified birthdate. |
The function returns the age on the present date for the value assigned to the Birthdate variable. |
AGEON |
For a given birth date, returns the age on a specified date. |
The function
returns |
DATEDIFF |
Returns the number of days between two specified dates. If the first date is greater than the second date, the value is returned as a negative number. |
The function returns |
DATEVALUE |
Returns the date value of a Date & Time resource based on the timezone settings in your Salesforce org. |
The function returns |
EOM |
For a specified date, returns the date of the last day of the month. |
The function returns |
MONTH |
For a specified date, returns the month as an integer (1-12). |
The function returns |
TODAY |
Returns today's date. | TODAY() returns today’s date. |
YEAR |
Returns the year of the specified date as an integer. |
The function returns
|
NOW |
Returns a date/time representing the current moment. | NOW() returns the current date and time. |
| Function | Description | Example |
|---|---|---|
ISNULL |
True if the value of a resource is null. |
The function
returns |
ISNOTNULL |
True if the value of a resource isn’t null. |
The
function returns |
LIKE |
True if the second parameter contains the first parameter. | LIKE(’A’, ‘ABC’) returns true. |
NOTLIKE |
True if the second parameter doesn't contain the first parameter. | NOTLIKE(’A’, ‘ABC’) returns false. |
BEGINS |
Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't. | BEGINS(MyString,CompareText),
where MyString, and CompareText are variables
of the data type Text . BEGINS(““Expression
Set”,“Express”)returns TRUE. |
ISNUMBER |
Returns TRUE if the string is a number. Returns FALSE if a string isn’t a number. | ISNUMBER(MyString),
where MyString is a variable of the data type Text . ISNUMBER(“10”)returns TRUE. ISNUMBER(“tty”)returns FALSE. |
| Function | Description | Example |
|---|---|---|
ABS |
Returns the absolute value of a number. The absolute value of a number is the number without its positive or negative sign. |
The function returns |
AVG |
Returns the average of two values. | AVG(3,5) returns 4. |
EXP |
Returns a value for e raised to the power of a number you specify. |
The function returns |
LOG |
Returns the base 10 logarithm or the power that the number 10 must be raised to for returning the number specified. |
The function returns |
LN |
Returns the natural logarithm or the power that the constant e (2.718281828) must be raised to for returning the specified number. |
The function returns |
MAX |
Returns the maximum value out of two values. | MAX(2,10) returns 10. |
MIN |
Returns the minimum value out of two values. | MIN(2,10) returns 2. |
POWER |
Returns the result of the first number raised to the power of the second number. | POWER(2, 3) returns 8 (2 x 2 x 2). |
SQRT |
Calculates the square root of a value. | SQRT(12 * 3) returns 6. |
SUM |
Returns the sum of two values. | SUM(1,2) returns 3. |
MOD |
Returns a remainder after a number is divided by a specified divisor. | MOD(4, 3) returns 1 |
ROUND |
Rounds the specified number or expression. | ROUND(3.1415, 2) returns 3.14 ROUND(3.1415 * 3, 0) returns 9. |
UP(Use with ROUND) |
Use with ROUND to specify that the rounding result is rounded up (away from zero). | ROUND(2.572, 2, UP) returns 2.58. |
DOWN(Use with ROUND) |
Use with ROUND to specify that the rounding result is rounded down (towards zero). | ROUND(2.572, 2, DOWN) returns 2.57. |
HALF_UP(Use with ROUND) |
Use with ROUND to specify that therounding result is rounded towards the nearest neighbor (up or down) unless the neighbors are equidistant, in which case it rounds up. | ROUND(2.575, 2, HALF_UP) returns 2.58. |
HALF_DOWN(Use with ROUND) |
Use with ROUND to specify that the rounding result is rounded rounded towards the nearest neighbor (up or down) unless the neighbors are equidistant, in which case it rounds down. |
ROUND(2.575, 2, HALF_DOWN) returns 2.57. |
HALF_EVEN(Use with ROUND) |
Use with ROUND to specify that the rounding result is rounded rounded towards the nearest neighbor (up or down) unless the neighbors are equidistant, in which case it rounds to the nearest even neighbor. Behaves as for ROUND HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND HALF_DOWN if it is even. |
ROUND(2.57, 1, HALF_EVEN) returns 2.6, which is rounded up to the nearest even one-decimal place. |
| Function | Description | Example |
|---|---|---|
CONTAIN |
True if the list of strings in the first parameter contains the string in the second parameter. Separate the strings in the list of strings in the first parameter with semicolons (;). |
|
REVERSE |
Returns the characters of the string in reverse order. | REVERSE(MyString),
where MyString is a variable of the data type Text. REVERSE(“Salesforce”)returns “ecrofselaS”. |
FIND |
Returns the position of a string in another string | FIND(search_text,text), where
search_text and text are variables of data
type Text. FIND(”@”,“admin@salesforce.com)
returns 6. |
LEFT |
Returns the specified number of characters from the beginning of a text string. | LEFT(MyString,MyPos), where
MyString is a variable of the data type Text and
MyPos is a variable of the data type Number.LEFT("www.salesforce.com",3)returns “www”. |
MID |
Returns the specified number of characters from the starting position of a text string. | MID(MyString,NumOfChar,StartingPos),
where MyString is a variable of the data type Text,
NumOfChar and StartingPos are variables of
the data type Number.MID("www.salesforce.com",10,5)returns “salesforce”. |
RIGHT |
Returns the specified number of characters from the end of a text string. | RIGHT(MyString,MyPos), where
MyString is a variable of the data type Text and
MyPos is a variable of the data type Number.RIGHT("www.salesforce.com",3)returns “com”. |
LEN |
Returns number of characters in the string | LEN(MyString), where
MyString is a variable of the data type Text. LEN("salesforce”)returns 10. |
INITCAP |
Returns string with initial caps - the first character of each word in upper case and the rest of the string in lowercase. | INITCAP(MyString),
where MyString is a variable of the data type Text . INITCAP(“expression set”)returns “Expression
Set”. |
LOWER |
Converts all the characters in the string in lowercase. | LOWER(MyString), where
MyString is a variable of the data type Text . LOWER(“Expression Set”)returns “expression
set”. |
UPPER |
Converts all letters in the specified text string to uppercase. | UPPER(MyString), where
MyString is a variable of the data type Text . UPPER(“expression set”)returns “EXPRESSION
SET”. |
SUBSTITUTE |
Substitutes old text with new text in a text string. | SUBSTITUTE(MyString,OldText,NewText),
where MyString, OldText, and
NewText are variables of the data type Text . SUBSTITUTE(“xyz@salesforce.com”,“xyz”,“itadmin”)returns
“itadmin@salesforce.com”. |
TEXT |
Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. | TEXT(MyValue). TEXT(Revenue)where Revenue is
$20000 returns “20000”. |
TRIM |
Removes the spaces and tabs from the beginning and end of a text string. | TRIM(MyString), where
MyString is a variable of the data type Text . TRIM(“ Expression Set ”)returns “Expression
Set”. |
VALUE |
Converts a text string to a number. | VALUE(MyString), where
MyString is a variable of the data type Text . VALUE(“10”)returns the number 10. |
BEGINS |
Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't. | BEGINS(MyString,CompareText),
where MyString, and CompareText are variables
of the data type Text . BEGINS(““Expression
Set”,“Express”)returns TRUE. |
LPAD |
Inserts characters that you specify to the left-side of a text string. | LPAD(MyString,PadLength,PadString),
where MyString, and PadString are variables of
the data type Text . PadLength is a variable of data type Number.
LPAD('my_company.com', 15,'z')returns
“zmycompany.com”. |
RPAD |
Inserts characters that you specify to the right-side of a text string. | RPAD(MyString,PadLength,PadString),
where MyString, and PadString are variables of
the data type Text . PadLength is a variable of data type Number.
RPAD('my_company.com',15,'z')returns
“mycompany.comz”. |

