# Functions you can use in formulas

- Product: Clastly
- Category: Fields
- Type: Reference
- Updated: 2026-10-29
- URL: https://www.clastly.com/support/fields/formula-functions/

You can use the following operators and functions in formula field expressions. Braces such as `{Price}` refer to fields.

## Operators

Enter operators with the keys in the formula editor. Choose comparison operators from the menu on the :ui[=] key. Multiplication and division are calculated before addition and subtraction. Use ( ) to calculate a part first.

| Operator | Description | Example |
| --- | --- | --- |
| `+` | Adds. Same as `sum`. | `{Price} + {Shipping}` |
| `−` or `-` | Subtracts. Same as `subtract`. | `{Price} − {Discount}` |
| `×` or `*` | Multiplies. Same as `multiply`. | `{Price} × {Quantity}` |
| `÷` or `/` | Divides. Same as `divide`. | `{Price} ÷ 2` |
| `=` | Returns true when the two sides are equal. Same as `equal`. | `{Status} = "Done"` |
| `≠`, `!=`, or `<>` | Returns true when the two sides are not equal. Same as `notEqual`. | `{Status} ≠ "Done"` |
| `>` | Returns true when the left side is greater than the right side. Same as `greater`. | `{Stock} > 5` |
| `≥` or `>=` | Returns true when the left side is greater than or equal to the right side. Same as `greaterOrEqual`. | `{Stock} ≥ 5` |
| `<` | Returns true when the left side is less than the right side. Same as `less`. | `{Stock} < 5` |
| `≤` or `<=` | Returns true when the left side is less than or equal to the right side. Same as `lessOrEqual`. | `{Stock} ≤ 5` |

## Arithmetic functions

| Name | Description | Example |
| --- | --- | --- |
| `sum` | Adds numbers and the elements of number lists. Empty values are ignored. | `sum({Price}, {Shipping}, 5)` → The total of Price, Shipping, and 5<br>`{Price} + {Shipping} + 5` |
| `subtract` | Subtracts the second value from the first. If any argument is empty, the result is empty. | `subtract({Price}, {Discount})` → Price minus Discount<br>`{Price} − {Discount}` |
| `multiply` | Multiplies the values together. If any argument is empty, the result is empty. | `multiply({Price}, {Quantity})` → Price multiplied by Quantity<br>`{Price} × {Quantity}` |
| `divide` | Divides the first value by the second. Dividing by 0 is an error. If any argument is empty, the result is empty. | `divide({Price}, 2)` → Half of Price<br>`{Price} ÷ 2` |
| `modulo` | Returns the remainder after dividing the first number by the second. Dividing by 0 is an error. If any argument is empty, the result is empty. The remainder has the same sign as the dividend. | `modulo({Quantity}, 12)` → The remainder after dividing Quantity by 12 |
| `power` | Raises the base to the exponent. If any argument is empty, the result is empty. | `power(2, 3)` → `8` (2 raised to the third power) |

## Number functions

| Name | Description | Example |
| --- | --- | --- |
| `average` | Returns the average of numbers and the elements of number lists. Empty values are ignored. | `average({Price}, {Shipping})` → The average of Price and Shipping |
| `minimum` | Returns the smallest of the numbers and list elements. Empty values are ignored. | `minimum({Price}, 1000)` → The smaller of Price and 1000 |
| `maximum` | Returns the largest of the numbers and list elements. Empty values are ignored. | `maximum({Quantity}, 1)` → Quantity or 1, whichever is larger |
| `round` | Rounds a value to the given number of decimal places. Places is a whole number from 0 to 10. Negative numbers are rounded by their absolute value. | `round(12.345, 2)` → `12.35` |
| `roundUp` | Rounds away from zero to the given number of decimal places. Places is a whole number from 0 to 10. | `roundUp(12.341, 2)` → `12.35` |
| `roundDown` | Rounds toward zero to the given number of decimal places. Places is a whole number from 0 to 10. | `roundDown(12.349, 2)` → `12.34` |
| `absolute` | Returns the value without its minus sign. | `absolute(-1500)` → `1500` |
| `squareRoot` | Returns the square root of a number that is 0 or greater. A negative number is an error. | `squareRoot(144)` → `12` |

## Functions that return a date

| Name | Description | Example |
| --- | --- | --- |
| `today` | Returns today's date in the device calendar, without a time. It refreshes when the day changes. | `today()` → Today's date |
| `now` | Returns the current date and time. It refreshes about every hour while the app is open. | `now()` → The current date and time |
| `addMinutes` | Moves a date and time forward by the given minutes. A negative number moves it back. The date must include a time. Works only with dates that include a time. | `addMinutes({Appointment}, 30)` → The date and time 30 minutes after Appointment |
| `addHours` | Moves a date and time forward by the given hours. A negative number moves it back. The date must include a time. Works only with dates that include a time. | `addHours({Appointment}, 2)` → The date and time 2 hours after Appointment |
| `addDays` | Adds calendar days to a date. A negative whole number moves it back. The amount must be a whole number. | `addDays({Due Date}, 7)` → The date 7 days after Due Date |
| `addWeeks` | Adds a whole number of weeks to a date. The amount must be a whole number. | `addWeeks({Due Date}, 2)` → The date 2 weeks after Due Date |
| `addMonths` | Adds a whole number of months to a date. The amount must be a whole number. | `addMonths({Due Date}, 1)` → The date 1 month after Due Date |
| `addYears` | Adds a whole number of years to a date. The amount must be a whole number. | `addYears({Due Date}, 1)` → The date 1 year after Due Date |

## Functions that return the difference between two dates

| Name | Description | Example |
| --- | --- | --- |
| `daysBetween` | Returns the number of calendar days from the start date to the end date. Times are ignored. Counts calendar days and ignores the time. If the end is before the start, the result is negative. | `daysBetween({Start Date}, {End Date})` → The number of calendar days from Start Date to End Date |
| `minutesBetween` | Returns the elapsed minutes between two date-times, truncated toward zero. Both dates must include a time. Truncates toward zero. Both dates must include a time. If the end is before the start, the result is negative. | `minutesBetween({Start Date}, {End Date})` → The elapsed minutes from Start Date to End Date |
| `hoursBetween` | Returns the elapsed hours between two date-times, truncated toward zero. Both dates must include a time. Truncates toward zero. Both dates must include a time. If the end is before the start, the result is negative. | `hoursBetween({Start Date}, {End Date})` → The elapsed hours from Start Date to End Date |
| `weeksBetween` | Returns the whole weeks between two dates, truncated toward zero. Days short of a full week are not counted. Divides the number of days by 7 and truncates toward zero. If the end is before the start, the result is negative. | `weeksBetween({Start Date}, {End Date})` → The number of complete weeks from Start Date to End Date |
| `monthsBetween` | Returns the complete calendar months between two dates. Days short of a full month are not counted. Counts only complete months and ignores the time. If the end is before the start, the result is negative. | `monthsBetween({Start Date}, {End Date})` → The number of complete calendar months from Start Date to End Date |
| `yearsBetween` | Returns the complete calendar years between two dates. Counts only complete years and ignores the time. If the end is before the start, the result is negative. | `yearsBetween({Start Date}, {End Date})` → The number of complete calendar years from Start Date to End Date |

## Functions that return part of a date

| Name | Description | Example |
| --- | --- | --- |
| `year` | Returns the year of a date. | `year({Due Date})` → The year of Due Date |
| `month` | Returns the month of a date, from 1 to 12. | `month({Due Date})` → The month of Due Date, from 1 to 12 |
| `dayOfMonth` | Returns the day of the month of a date, from 1 to 31. | `dayOfMonth({Due Date})` → The day of the month of Due Date, from 1 to 31 |
| `weekday` | Returns the weekday as a number from 1 (Monday) to 7 (Sunday). | `weekday({Due Date})` → The weekday of Due Date: Monday is 1 and Sunday is 7 |
| `hour` | Returns the hour of a date-time, from 0 to 23. The date must include a time. Works only with dates that include a time. | `hour({Appointment})` → The hour of Appointment, from 0 to 23 |
| `minute` | Returns the minute of a date-time, from 0 to 59. The date must include a time. Works only with dates that include a time. | `minute({Appointment})` → The minute of Appointment, from 0 to 59 |

## Text functions

| Name | Description | Example |
| --- | --- | --- |
| `join` | Joins fields and text into one piece of text. Numbers, dates, checkboxes, and selections are joined as they appear on screen. A checkbox becomes "Yes" or "No". | `join({Name}, " - ", {Status})` → Name and Status separated by " - " |
| `length` | Returns the number of characters in text, or the number of elements in a list. | `length({Name})` → The number of characters in Name<br>`{Name}.length()` |
| `uppercase` | Converts text to uppercase. | `uppercase("Clastly")` → `"CLASTLY"`<br>`{Name}.uppercase()` |
| `lowercase` | Converts text to lowercase. | `lowercase("Clastly")` → `"clastly"`<br>`{Name}.lowercase()` |
| `trim` | Removes leading and trailing whitespace and line breaks from text. | `trim("  Clastly  ")` → `"Clastly"`<br>`{Notes}.trim()` |
| `replaceAll` | Replaces every occurrence of the search text with the replacement text. If the search text is empty, the original text is returned unchanged. | `replaceAll({Name}, "old", "new")` → Name with every "old" replaced by "new" |
| `left` | Returns the given number of characters from the left end of the text. The count must be a whole number, 0 or greater. | `left({Name}, 3)` → The first three characters of Name |
| `right` | Returns the given number of characters from the right end of the text. The count must be a whole number, 0 or greater. | `right({Name}, 3)` → The last three characters of Name |
| `toNumber` | Converts text to a number. When the text cannot be converted, the result is empty. Full-width digits and comma thousands separators are accepted. | `toNumber("1500")` → The number `1500` |
| `toDateTime` | Converts text to a date and time. When the text cannot be converted, the result is empty. Accepts text such as `2026-10-09T09:00:00Z`, `2026-10-09`, `2026/10/09`, and `2026-10-09 09:00`. Text without a time zone is read in the device's time zone. | `toDateTime("2026-10-09T09:00:00Z")` → October 9, 2026 at 09:00 UTC, displayed in the local time zone |

## List functions

| Name | Description | Example |
| --- | --- | --- |
| `filter` | Keeps the list elements that satisfy a condition. In the condition, `current` refers to each element. | `[1, 2, 3].filter(current > 1)` → A list containing 2 and 3 |
| `map` | Applies an expression to each list element. In the expression, `current` refers to each element. | `[1, 2].map(current * 2)` → A list containing 2 and 4 |
| `median` | Returns the median of numbers and numeric lists. With an even number of elements, it is the average of the two middle values. | `median([1, 3], 2)` → `2`, the middle value of 1, 2, and 3 |
| `flat` | Flattens one level of nested lists. Use `flat` before passing a nested list to a number function. | `flat([[1, 2], [3]])` → A list containing 1, 2, and 3 |

## Logic and comparison functions

| Name | Description | Example |
| --- | --- | --- |
| `if` | Returns the second value when the condition is true and the third when it is false. The result type follows the result type of the formula field. | `if({Completed}, "Done", "Pending")` → `"Done"` when Completed is checked, otherwise `"Pending"` |
| `and` | Returns true when every value is true. A missing value counts as false. | `and({Completed}, {Approved})` → True when both Completed and Approved are checked |
| `or` | Returns true when any value is true. A missing value counts as false. | `or({Completed}, {Approved})` → True when either Completed or Approved is checked |
| `not` | Returns true when the value is false. A missing value counts as false. | `not({Completed})` → True when Completed is not checked |
| `isEmpty` | Returns true when the value is missing, blank text, or an empty selection, file list, or list. Numbers and checkboxes are never empty. | `isEmpty({Notes})` → True when Notes is empty |
| `contains` | Returns true when text contains the search string or a list contains the searched value. Text matching is case sensitive. An empty search string matches any text. | `contains({Name}, "Book")` → True when Name contains "Book" with the same capitalization |
| `equal` | Returns true when both sides are equal. Works with numbers, dates, checkboxes, and text. | `equal({Status}, "Done")` → True when Status is "Done"<br>`{Status} = "Done"` |
| `notEqual` | Returns true when the two sides are not equal. Works with numbers, dates, checkboxes, and text. | `notEqual({Status}, "Done")` → True when Status is not "Done"<br>`{Status} ≠ "Done"` |
| `greater` | Returns true when the left side is greater than the right side. Compares two numbers or two dates. | `greater({Price}, 1000)` → True when Price is greater than 1000<br>`{Stock} > 5` |
| `greaterOrEqual` | Returns true when the left side is greater than or equal to the right side. Compares two numbers or two dates. | `greaterOrEqual({Price}, 1000)` → True when Price is at least 1000<br>`{Stock} ≥ 5` |
| `less` | Returns true when the left side is less than the right side. Compares two numbers or two dates. | `less({Quantity}, 10)` → True when Quantity is less than 10<br>`{Stock} < 5` |
| `lessOrEqual` | Returns true when the left side is less than or equal to the right side. Compares two numbers or two dates. | `lessOrEqual({Quantity}, 10)` → True when Quantity is at most 10<br>`{Stock} ≤ 5` |
