Explore Layer's formula V2 capabilities for date, text, and math functions. Learn how to use DATE, CONCATENATE, ROUND, and more to enhance your data calculations.

Mike Lee
Tuesday, May 12, 2026
Below is a complete reference for all available formula functions in Layer. Each entry includes the syntax, a description, parameters, return type, examples, and related functions. Read the technical documentation in Layer →
Array Functions
Functions for working with arrays and collections of values.
ARRAY(value1, value2, ...)
Creates an array from a list of values.
Parameters:
value1, value2, ...(any type): Values to include in the array. All values must be of the same type.
Returns: array.
Examples:
Related: ARRAYAT, ARRAYLENGTH
ARRAYAT(array, index)
Gets the value at a specified index in an array.
Parameters:
array(array): The array to accessindex(number): Zero-based index position
Returns: any. The value at the specified index, or null if out of bounds.
Examples:
Related: FIRST, LAST, ARRAYLENGTH
ARRAYFLATTEN(array)
Expands an array of objects with quantity into a flat array.
Parameters:
array(array of objects): Array containing objects with aquantityproperty
Returns: array. Flattened array with each object repeated according to its quantity, with quantity set to 1.
Examples:
Related: ARRAY, UNIQUE
ARRAYJOIN(array, delimiter)
Joins an array of strings into a single string.
Parameters:
array(array of strings): Array containing string valuesdelimiter(string): String to place between joined values
Returns: string. Joined string.
Examples:
Related: ARRAY, CONCATENATE
ARRAYLENGTH(array)
Returns the number of items in an array.
Parameters:
array(array): The array to measure
Returns: number. Count of items in the array.
Examples:
Related: ARRAYAT, FIRST, LAST
AVERAGE(numbers)
Calculates the average (mean) of an array of numbers.
Parameters:
numbers(array of numbers): Array of numeric values to average
Returns: number. The arithmetic mean of the values.
Examples:
Related: SUM, MEDIAN, MIN, MAX
COUNTEMPTY(values)
Counts the number of empty values in an array. An empty value is anything that is not a number, a string that is empty or contains only whitespace, a falsy boolean value, null, or undefined.
Parameters:
values(array): Array of values to evaluate
Returns: number. Count of empty values.
Examples:
Related: COUNTNOTEMPTY
COUNTNOTEMPTY(values)
Counts the number of non-empty values in an array. A non-empty value is a number, a string that is not empty and contains more than whitespace, or a truthy boolean value.
Parameters:
values(array): Array of values to evaluate
Returns: number. Count of non-empty values.
Examples:
Related: COUNTEMPTY
FIRST(array)
Gets the value at the first index in an array.
Parameters:
array(array): The array to access
Returns: any. The first element, or null if the array is empty.
Examples:
Related: LAST, ARRAYAT, ARRAYLENGTH
LAST(array)
Gets the value at the last index in an array.
Parameters:
array(array): The array to access
Returns: any. The last element, or null if the array is empty.
Examples:
Related: FIRST, ARRAYAT, ARRAYLENGTH
MATRIXMULTIPLY(array1, array2)
Multiplies two arrays of numbers element-wise. If arrays have different lengths, the shorter is padded with 0s.
Parameters:
array1(array of numbers): First array of numbersarray2(array of numbers): Second array of numbers
Returns: array of numbers. Element-wise product.
Examples:
Related: PRODUCT, ARRAY
MAX(numbers)
Returns the maximum value from a list of numbers.
Parameters:
numbers(array of numbers): Array of numeric values to evaluate
Returns: number. The largest value in the array.
Examples:
Related: MIN, AVERAGE, RANGE
MEDIAN(numbers)
Calculates the median of an array of numbers.
Parameters:
numbers(array of numbers): Array of numeric values
Returns: number. The median value (middle value when sorted).
Examples:
Related: AVERAGE, MIN, MAX
MIN(numbers)
Returns the minimum value from a list of numbers.
Parameters:
numbers(array of numbers): Array of numeric values to evaluate
Returns: number. The smallest value in the array.
Examples:
Related: MAX, AVERAGE, RANGE
PRODUCT(numbers)
Multiplies all numbers in an array.
Parameters:
numbers(array of numbers): Array of numeric values to multiply
Returns: number. The product of all values.
Examples:
Related: SUM, MATRIXMULTIPLY
RANGE(numbers)
Returns the difference between the highest and lowest numerical values in an array.
Parameters:
numbers(array of numbers): Array of numeric values
Returns: number. The range (max minus min).
Examples:
Related: MAX, MIN, AVERAGE
SUM(numbers)
Sums an array of numerical values.
Parameters:
numbers(array of numbers): Array of numeric values to sum
Returns: number. The sum of all values.
Examples:
Related: AVERAGE, PRODUCT, MIN, MAX
UNIQUE(values)
Consolidates an array by combining equivalent values and storing the quantity on the returned value.
Parameters:
values(array): Array of values to consolidate
Returns: array of objects. Array where each unique value appears once with a quantity property.
Examples:
Related: ARRAY, ARRAYFLATTEN, ARRAYLENGTH
Text Functions
Functions for working with strings and text manipulation.
CONCATENATE(text1, text2, ...)
Concatenates two or more strings into one.
Parameters:
text1, text2, ...(string): Strings to concatenate
Returns: string. Combined string.
Examples:
Related: ARRAYJOIN, SUBSTITUTE
DATE(value)
Converts a value to a date.
Parameters:
value(string, number, or date): Value to convert. Accepts ISO 8601 strings, timestamps, or existing date values.
Returns: date. The parsed date object.
Examples:
Related: DATETOSTRING, NOW
ENCODEURICOMPONENT(text)
Replaces characters with encoded equivalents for use in constructing URLs or URIs.
Parameters:
text(string): String to encode for URI use
Returns: string. URL-encoded string.
Examples:
Related: CONCATENATE, LEFT, RIGHT
EQUALS(value1, value2)
Checks if two values are equal. Inputs must be of the same type to be considered equal.
Parameters:
value1(any): First value to comparevalue2(any): Second value to compare
Returns: boolean. TRUE if equal, FALSE otherwise.
Examples:
Related: NOTEQUALS, IF
LEFT(text, count)
Extracts a substring of the specified size from the start of a string.
Parameters:
text(string): The string to extract fromcount(number): Number of characters to extract from the left
Returns: string. Substring of the specified length.
Examples:
Related: RIGHT, MID, LENGTH
LENGTH(text)
Returns the number of characters in a string.
Parameters:
text(string): String to measure
Returns: number. Number of characters.
Examples:
Related: LEFT, RIGHT, MID, ARRAYLENGTH
LOWER(text)
Converts a string to all lowercase.
Parameters:
text(string): String to convert
Returns: string. Lowercase string.
Examples:
Related: UPPER, TRIM
MID(text, start_index, length)
Extracts a substring from a string.
Parameters:
text(string): The string to extract fromstart_index(number): Zero-based starting positionlength(number): Number of characters to extract
Returns: string. Extracted substring.
Examples:
Related: LEFT, RIGHT, LENGTH
NOTEQUALS(value1, value2)
Checks if two values are not equal. Inputs must be of the same type for proper comparison.
Parameters:
value1(any): First value to comparevalue2(any): Second value to compare
Returns: boolean. TRUE if not equal, FALSE if equal.
Examples:
Related: EQUALS, IF
REGEXEXTRACT(text, pattern)
Extracts a substring that matches a regular expression.
Parameters:
text(string): The string to search inpattern(string): Regular expression pattern
Returns: string. First match found, or empty string if no match.
Examples:
Related: REGEXMATCH, REGEXREPLACE, SEARCH
REGEXMATCH(text, pattern)
Checks if a string matches a regular expression.
Parameters:
text(string): The string to testpattern(string): Regular expression pattern
Returns: boolean. TRUE if pattern matches, FALSE otherwise.
Examples:
Related: REGEXEXTRACT, REGEXREPLACE, SEARCH
REGEXREPLACE(text, pattern, replacement)
Replaces a substring that matches a regular expression.
Parameters:
text(string): The string to search inpattern(string): Regular expression pattern to matchreplacement(string): Replacement string
Returns: string. String with replacements made.
Examples:
Related: REGEXMATCH, REGEXEXTRACT, SUBSTITUTE
REPEAT(text, count)
Repeats a string a specified number of times.
Parameters:
text(string): String to repeatcount(number): Number of times to repeat
Returns: string. Repeated string.
Examples:
Related: CONCATENATE, ARRAYJOIN
RIGHT(text, count)
Extracts a substring of the specified size from the end of a string.
Parameters:
text(string): The string to extract fromcount(number): Number of characters to extract from the right
Returns: string. Substring of the specified length.
Examples:
Related: LEFT, MID, LENGTH
SEARCH(text, search_text)
Searches a string for another string and returns the index position of the found string.
Parameters:
text(string): The string to search insearch_text(string): The string to search for
Returns: number. Zero-based index of first occurrence, or -1 if not found.
Examples:
Related: REGEXMATCH, REGEXEXTRACT, SUBSTITUTE
SUBSTITUTE(text, search_text, replacement_text)
Substitutes a string with another string.
Parameters:
text(string): The string to search insearch_text(string): The string to find and replacereplacement_text(string): The replacement string
Returns: string. String with substitutions made.
Examples:
Related: REGEXREPLACE, CONCATENATE
TRIM(text)
Trims whitespace from a string.
Parameters:
text(string): String to trim
Returns: string. String with leading and trailing whitespace removed.
Examples:
Related: LOWER, UPPER, LENGTH
UPPER(text)
Converts a string to all uppercase.
Parameters:
text(string): String to convert
Returns: string. Uppercase string.
Examples:
Related: LOWER, TRIM
Date Functions
Functions for working with dates and times.
DATEADDDAYS(date, days)
Adds a specified number of days to a date.
Parameters:
date(date): The starting datedays(number): Number of days to add (can be negative)
Returns: date. New date after adding days.
Examples:
Related: DATEADDWEEKS, DATEADDMONTHS, DATESUBTRACTDAYS
DATEADDHOURS(date, hours)
Adds a specified number of hours to a date.
Parameters:
date(date): The starting datehours(number): Number of hours to add (can be negative)
Returns: date. New date after adding hours.
Examples:
Related: DATEADDMINUTES, DATEADDSECONDS, DATESUBTRACTHOURS
DATEADDMINUTES(date, minutes)
Adds a specified number of minutes to a date.
Parameters:
date(date): The starting dateminutes(number): Number of minutes to add (can be negative)
Returns: date. New date after adding minutes.
Examples:
Related: DATEADDHOURS, DATEADDSECONDS, DATESUBTRACTMINUTES
DATEADDMONTHS(date, months)
Adds a specified number of months to a date.
Parameters:
date(date): The starting datemonths(number): Number of months to add (can be negative)
Returns: date. New date after adding months.
Examples:
Related: DATEADDYEARS, DATEADDWEEKS, DATESUBTRACTMONTHS
DATEADDSECONDS(date, seconds)
Adds a specified number of seconds to a date.
Parameters:
date(date): The starting dateseconds(number): Number of seconds to add (can be negative)
Returns: date. New date after adding seconds.
Examples:
Related: DATEADDMINUTES, DATEADDHOURS, DATESUBTRACTSECONDS
DATEADDWEEKS(date, weeks)
Adds a specified number of weeks to a date.
Parameters:
date(date): The starting dateweeks(number): Number of weeks to add (can be negative)
Returns: date. New date after adding weeks.
Examples:
Related: DATEADDDAYS, DATEADDMONTHS, DATESUBTRACTWEEKS
DATEADDYEARS(date, years)
Adds a specified number of years to a date.
Parameters:
date(date): The starting dateyears(number): Number of years to add (can be negative)
Returns: date. New date after adding years.
Examples:
Related: DATEADDMONTHS, DATEADDWEEKS, DATESUBTRACTYEARS
DATEISAFTER(date1, date2)
Checks if the first date is after the second date.
Parameters:
date1(date): First date to comparedate2(date): Second date to compare
Returns: boolean. TRUE if date1 is after date2, FALSE otherwise.
Examples:
Related: DATEISBEFORE, DATEISSAME
DATEISBEFORE(date1, date2)
Checks if the first date is before the second date.
Parameters:
date1(date): First date to comparedate2(date): Second date to compare
Returns: boolean. TRUE if date1 is before date2, FALSE otherwise.
Examples:
Related: DATEISAFTER, DATEISSAME
DATEISSAME(date1, date2)
Checks if two dates are the same.
Parameters:
date1(date): First date to comparedate2(date): Second date to compare
Returns: boolean. TRUE if dates are identical, FALSE otherwise.
Examples:
Related: DATEISSAMEDAY, DATEISSAMEWEEK, DATEISSAMEMONTH
DATEISSAMEDAY(date1, date2)
Checks if two dates are on the same day.
Parameters:
date1(date): First datedate2(date): Second date
Returns: boolean. TRUE if dates are on the same calendar day, FALSE otherwise.
Examples:
Related: DATEISSAMEWEEK, DATEISSAMEMONTH, DATEISSAMEYEAR
DATEISSAMEHOUR(date1, date2)
Checks if two dates are in the same hour.
Parameters:
date1(date): First datedate2(date): Second date
Returns: boolean. TRUE if in the same hour, FALSE otherwise.
Examples:
Related: DATEISSAMEMINUTE, DATEISSAMEDAY
DATEISSAMEMINUTE(date1, date2)
Checks if two dates are in the same minute.
Parameters:
date1(date): First datedate2(date): Second date
Returns: boolean. TRUE if in the same minute, FALSE otherwise.
Examples:
Related: DATEISSAMEHOUR, DATEADDSECONDS
DATEISSAMEMONTH(date1, date2)
Checks if two dates are in the same month.
Parameters:
date1(date): First datedate2(date): Second date
Returns: boolean. TRUE if in the same calendar month, FALSE otherwise.
Examples:
Related: DATEISSAMEWEEK, DATEISSAMEYEAR
DATEISSAMEWEEK(date1, date2)
Checks if two dates are in the same week. Uses ISO week numbering (Monday through Sunday).
Parameters:
date1(date): First datedate2(date): Second date
Returns: boolean. TRUE if in the same ISO week, FALSE otherwise.
Examples:
Related: DATEISSAMEMONTH, DATEISSAMEDAY
DATEISSAMEYEAR(date1, date2)
Checks if two dates are in the same year.
Parameters:
date1(date): First datedate2(date): Second date
Returns: boolean. TRUE if in the same calendar year, FALSE otherwise.
Examples:
Related: DATEISSAMEMONTH, DATEISSAMEWEEK
DATESUBTRACTDAYS(date, days)
Subtracts a specified number of days from a date.
Parameters:
date(date): The starting datedays(number): Number of days to subtract
Returns: date. New date after subtracting days.
Examples:
Related: DATEADDDAYS, DATESUBTRACTWEEKS
DATESUBTRACTHOURS(date, hours)
Subtracts a specified number of hours from a date.
Parameters:
date(date): The starting datehours(number): Number of hours to subtract
Returns: date. New date after subtracting hours.
Examples:
Related: DATEADDHOURS, DATESUBTRACTMINUTES
DATESUBTRACTMINUTES(date, minutes)
Subtracts a specified number of minutes from a date.
Parameters:
date(date): The starting dateminutes(number): Number of minutes to subtract
Returns: date. New date after subtracting minutes.
Examples:
Related: DATEADDMINUTES, DATESUBTRACTHOURS
DATESUBTRACTMONTHS(date, months)
Subtracts a specified number of months from a date.
Parameters:
date(date): The starting datemonths(number): Number of months to subtract
Returns: date. New date after subtracting months.
Examples:
Related: DATEADDMONTHS, DATESUBTRACTYEARS
DATESUBTRACTSECONDS(date, seconds)
Subtracts a specified number of seconds from a date.
Parameters:
date(date): The starting dateseconds(number): Number of seconds to subtract
Returns: date. New date after subtracting seconds.
Examples:
Related: DATEADDSECONDS, DATESUBTRACTMINUTES
DATESUBTRACTWEEKS(date, weeks)
Subtracts a specified number of weeks from a date.
Parameters:
date(date): The starting dateweeks(number): Number of weeks to subtract
Returns: date. New date after subtracting weeks.
Examples:
Related: DATEADDWEEKS, DATESUBTRACTDAYS
DATESUBTRACTYEARS(date, years)
Subtracts a specified number of years from a date.
Parameters:
date(date): The starting dateyears(number): Number of years to subtract
Returns: date. New date after subtracting years.
Examples:
Related: DATEADDYEARS, DATESUBTRACTMONTHS
DATETOSTRING(date, format)
Converts a date to a string using date-fns format tokens.
Parameters:
date(date): The date to formatformat(string): Format string using date-fns tokens
Common format tokens:
yyyy: 4-digit yearMM: 2-digit month (01–12)dd: 2-digit day (01–31)HH: 2-digit hour (00–23)mm: 2-digit minute (00–59)ss: 2-digit second (00–59)
Returns: string. Formatted date string.
Examples:
Related: DATE, DATEADDDAYS
DAY(date)
Returns the day of the week for a date as a number 0–6, where 0 is Sunday.
Parameters:
date(date): The date to evaluate
Returns: number. Day of week (0 = Sunday, 1 = Monday, ..., 6 = Saturday).
Examples:
Related: MONTH, YEAR, WEEK
HOUR(date)
Returns the hour of the day for a date.
Parameters:
date(date): The date to evaluate
Returns: number. Hour of day (0–23).
Examples:
Related: DATEADDHOURS, DATEISSAMEHOUR
ISWEEKDAY(date)
Checks if a date is a weekday (Monday through Friday).
Parameters:
date(date): The date to evaluate
Returns: boolean. TRUE if weekday, FALSE if weekend.
Examples:
Related: ISWEEKEND, DAY
ISWEEKEND(date)
Checks if a date is a weekend (Saturday or Sunday).
Parameters:
date(date): The date to evaluate
Returns: boolean. TRUE if weekend, FALSE if weekday.
Examples:
Related: ISWEEKDAY, DAY
MONTH(date)
Returns the month for a date as a number 0–11, where 0 is January.
Parameters:
date(date): The date to evaluate
Returns: number. Month (0 = January, 1 = February, ..., 11 = December).
Examples:
Related: DAY, YEAR, DATEISSAMEMONTH
WEEK(date)
Returns the week number for a date using the ISO week numbering system. The first day of the week is Monday.
Parameters:
date(date): The date to evaluate
Returns: number. ISO week number (1–53).
Examples:
Related: DAY, MONTH, DATEISSAMEWEEK
YEAR(date)
Returns the year for a date.
Parameters:
date(date): The date to evaluate
Returns: number. The year (e.g., 2024).
Examples:
Related: MONTH, DAY, DATEISSAMEYEAR
Logical Functions
Functions for conditional logic and truth values.
IF(condition, value_if_true, value_if_false)
Returns a value based on a condition.
Parameters:
condition(boolean): The condition to evaluatevalue_if_true(any): Value returned if condition isTRUEvalue_if_false(any): Value returned if condition isFALSE
Returns: any. value_if_true or value_if_false based on the condition.
Examples:
Related: EQUALS, NOTEQUALS
Utility Functions
Functions for no-input constants and other utilities.
FALSE()
Returns the logical value FALSE.
Parameters: None.
Returns: boolean. FALSE.
Examples:
Related: TRUE, IF
NOW()
Returns the current date and time when the formula is executed.
Parameters: None.
Returns: date. Current date and time in UTC.
Examples:
Related: DATE, DATEADDDAYS
PI()
Returns the value of PI.
Parameters: None.
Returns: number. Mathematical constant π ≈ 3.14159265359.
Examples:
Related: PRODUCT, AVERAGE
TRUE()
Returns the logical value TRUE.
Parameters: None.
Returns: boolean. TRUE.
Examples:
Related: FALSE, IF

