Field - Formula V2

Field - Formula V2

Explore Layer's Formula V2 functions for arrays, text, dates, logic, and utilities. Complete reference with syntax, parameters, return types, and examples, including the new DateDiff, IsEmpty, IsZero, Newline, and Value functions.

This page documents the new and updated formula functions added in the formula-v2 release. For the full reference of all available formula functions, see the complete formula-v2 documentation →. Read the technical documentation in Layer →

Text Functions

NEWLINE()

New in this release. Inserts a line break, for building cleanly formatted, concatenated text output.

Parameters: None.

Returns: string. A line break.

Examples:

CONCATENATE("Line 1", NEWLINE(), "Line 2")

Related: CONCATENATE, ARRAYJOIN

TOSTRING(value)

Updated in this release to accept plain strings and single-choice field options in addition to its existing inputs. Converts a number, date, or single-choice value into a text string.

Parameters: value (number, date, string, or single-choice option).

Returns: string.

Related: VALUE, CONCATENATE

VALUE(value)

New in this release. Converts text or a single-choice value into a number.

Parameters: value (string or single-choice value).

Returns: number. The numeric value, or null if the value is empty or not a number. Mixed numeric-and-text strings such as "123abc" return null. For a multi-select field, VALUE sums all selected option values.

Examples:

VALUE("42") 42
VALUE("  3.5 ") 3.5
VALUE("123abc") null

Related: TOSTRING, SUM

Date Functions

DATEDIFF(start_date, end_date, unit)

New in this release. Returns the difference between two dates in a chosen unit.

Parameters: start_date (date). end_date (date). unit (string): one of "day", "hour", "minute", "month", "second", "week", or "year".

Returns: number. The number of complete units between the two dates (for example, dates 18 months apart return 1 for "year", not 1.5). Returns null if either date is invalid or the unit is not recognized.

Examples:

DATEDIFF(2024-01-01, 2024-01-15, "day") 14
DATEDIFF(2024-01-01, 2025-07-01, "year") 1

Related: DATESUBTRACTDAYS, DAY, DATEISAFTER

Logical Functions

ISEMPTY(value)

New in this release. Checks if a value is empty, null, or undefined.

Parameters: value (any).

Returns: boolean. TRUE for null, undefined, empty strings, whitespace-only strings, and empty arrays.

Examples:

ISEMPTY("") TRUE
ISEMPTY("   ") TRUE
ISEMPTY("Layer") FALSE

Related: IF, COUNTEMPTY

ISZERO(value)

New in this release. Checks if a numeric value is exactly zero.

Parameters: value (number).

Returns: boolean. TRUE if the value is zero. Returns null if the value is not a number.

Examples:

ISZERO(0) TRUE
ISZERO(5) FALSE

Related: IF, EQUALS