Skip to main content
Use this page to look up a function, an operator, or how a formula treats a blank field. Each entry shows what you type, what it does, and a before and after example. New to formulas? Start with What formulas are and when to use one. A formula reads fields from one record and gives back one answer. In a list filter, the answer must be true or false. In a list column, the answer is what each row shows. Formulas never change your data. In every table on this page, the quotes around text show exactly where it starts and ends, so you can see spaces. The quotes are not part of the value. Rows marked “same formula” use the formula from the row above.

Terms used on this page

What counts as blank

Four checks ask “is there anything here?” in four different ways. They disagree on spaces-only text, 0, and false, so the check you pick matters. How to choose:
  • Use empty() and exists() to ask whether a field has anything real in it. They treat spaces-only text as nothing, and 0 as something.
  • Use flag() to ask whether a field says yes. See Check for blank values below.
  • Use === null only to ask whether the field has no value at all. Empty text does not match.
  • Let a value count as true or false only when you want 0 and false treated as nothing, or when you are sure the field never holds spaces-only text.

Read a field

Field names must match exactly, including capitalization. A misspelled name reads as no value, and MK does not show an error. Always include the record type. A bare $`email` looks for a record type called “email” and finds nothing.

Values you can type

Text and numbers mix in a few ways:
  • == treats a field holding the text 5 as equal to the number 5.
  • Math works on a field whose text looks like a number. If lead.score holds the text 5, then $`lead.score` + 1 gives 6.
  • Math on a field whose text is not a number fails with an error. If person.firstName holds Ann, then $`person.firstName` + 1 is rejected.

Compare values

=== and !== work the same as == and !=. Text comparisons are case-sensitive, so 'VP' does not equal 'vp'. To ignore case, convert the field first, as in $`person.title`.toLowerCase() == 'vp'. A field with no value only equals another no value. So $`person.title` == '' is false when the title has no value. Use empty($person.title) to catch both. Before and after
In < and > comparisons, no value counts as 0. That makes $`company.employeeCount` < 500 true for a company with no employee count, and $`company.employeeCount` > 500 false. To leave those records out, check first: exists($`company.employeeCount`) && $`company.employeeCount` < 500.

Combine conditions

&& and || do not always give back true or false. They give back one of the two sides, chosen by whether it counts as true. 'a' && 'b' gives 'b'. '' || 'b' gives 'b'. In a filter, make both sides conditions, such as comparisons or empty(), so the answer is always true or false. || and ?? differ in what they skip:
  • || skips anything that counts as false: no value, empty text, 0, and false. It does not skip spaces-only text.
  • ?? skips only no value. It keeps empty text, spaces-only text, and 0.
Use ?? when 0 is a real answer. Use || when empty text should fall through. Neither one treats spaces-only text as nothing. To handle that, see Handle blank and messy values in formulas. When you mix && and || in one formula, add parentheses to show which goes first, as in (exists($`person.email`) || exists($`person.phone`)) && $`person.lifecycleStage` == 'lead'. Before and after

Do math and join text

Before and after Three rules to know before you use + and math:
  • To join two fields, include some typed text between them, even if it is only a space. $`person.firstName` + $`person.lastName` tries to add the two fields as numbers and fails with an error. $`person.firstName` + ' ' + $`person.lastName` joins them.
  • When joining, a field with no value turns the whole result into no value. Empty text is fine. Handle blank and messy values in formulas shows the fix.
  • In math, no value counts as 0. $`company.annualRevenue` / 12 gives 0 for a company with no revenue. It does not give no value. Handle blank and messy values in formulas shows how to leave those rows empty.

Choose a value

You can chain choices to sort records into more than two groups. MK checks them from left to right and stops at the first condition that is true:
Before and after

Check for blank values

empty() and exists() always give back true or false. They never give back no value, and they never fail on a field that has nothing in it. flag() is for fields that spell out a yes or no in words, instead of holding a true or false value. It returns true for these values, in any capitalization: true, t, yes, y, on, and 1. It also returns true for the number 1. Everything else is false. That includes no value, empty text, 0, 2, no, maybe, and any word flag() does not recognize. Spaces are not removed, so ' yes ' is false. Without flag(), the text 'no' and the text 'false' both count as true, because they are not empty. Use flag() whenever a field holds words like these. Before and after

Chain values together

Checks combine. You can test several fields at once with empty(a, b) and exists(a, b), pick the first filled value, and guard a field before you use it. Handle blank and messy values in formulas walks through each pattern with before and after tables.

Common patterns

Work with text

Text functions go after a field or a piece of text, like $`person.email`.toLowerCase(). If the field has no value, the result is no value. That includes .length. A field with empty text has a length of 0. Before and after Some rules for replace, replaceAll, and split:
  • The text you search for must be typed in, and it cannot be empty. It cannot come from a field.
  • The replacement must be fixed text with no $ in it. To use a field as the replacement, write it as () => field, for example $`lead.template`.replace('{{name}}', () => $`person.firstName`).
  • Pattern matching (regular expressions) is not available.

Work with lists of values

A list can be one you type, like ['ceo', 'cfo'], or a field that holds several values, such as tags. In the functions that take e => …, e stands for each item in turn. You can name it anything, such as tag => …. Before and after Some behaviors to know:
  • .includes on a typed list works as “is one of.” It follows the same matching as ==, so ['1'].includes(1) is true.
  • .toSorted() sorts numbers by value, so [10, 2, 1] becomes [1, 2, 10]. It always sorts low to high, and items with no value go last.
  • A list function used on something that is not a list gives no value instead of an error.
  • A function inside e => … can read fields, but cannot use the e of an outer function.

Other forms

Before and after

What formulas can’t do

MK checks a formula when you enter it. If it uses something outside what this page describes, MK rejects it and points to the spot, like this:
These are not available:
  • Remainder (%), bitwise operators, and optional chaining (?.)
  • Regular expressions
  • Assigning values, or writing more than one statement
  • Functions or text and list methods not listed on this page
  • Fields chosen by another field, such as a[$`b`]
  • Reading another record, such as a person’s company, from a list formula. A list formula reads the record in each row.
  • split(id, salt), a function used to divide people into test groups in content routing. It does not work in list filters or columns.
If a formula you expect to work is rejected, or gives an answer that this page does not explain, contact allGood support. Include the formula, the record you tested it on, and the full error message or the unexpected result.