> ## Documentation Index
> Fetch the complete documentation index at: https://coconut-grid.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Formulas

Create and manage formulas used in the data grid.

## Create Formula

Open the Formula Editor to create a formula.

<Steps>
  <Step title="Open Formula Editor">
    Open the Formula Editor from one of the following.

    * From the Columns dialog, open the **Formula** tab and click **Formula Editor**
    * From inputs that support formulas, click the **Formula Editor**
  </Step>

  <Step title="Enter formula details">
    Enter the required information.

    * `Column Label` – The header text shown in the data grid
    * `Data Type` – The formula’s output type
    * `Formula` – Expression using fields, operators, and functions
    * `Treat blank fields as zeroes / blanks` – How blanks are evaluated
  </Step>

  <Step title="Validate">
    Click **Validate** to check the formula syntax.
  </Step>

  <Step title="Apply">
    Click **Apply** to use the formula.
  </Step>
</Steps>

## Edit Formula

Update an existing formula.

<Steps>
  <Step title="Open Formula Editor">
    Open the Formula Editor from one of the following.

    * From a formula column, open the Edit Column dialog and click **Formula Editor**.
    * From inputs that support formulas, click the **Formula Editor**
  </Step>

  <Step title="Update formula">
    Modify the formula and settings.
  </Step>

  <Step title="Save">
    Click **Save** to apply changes.
  </Step>
</Steps>

## Formula Syntax

Understand how to write formulas.

* Type formulas directly or insert from the editor pickers
* Insert fields, functions, and operators at the end of the current formula
* Use parentheses `()` to control calculation order
* Field names are case-sensitive; functions and operators are not

## Built-in functions

* **Date & Time**

<table><thead><tr><th width="203">Function Name</th><th>Syntax and Description</th></tr></thead><tbody><tr><td>ADDMONTHS</td><td>ADDMONTHS(date,num)<br />Add the num months to the date, using the last date of the month if date is the last day of the month or adding num months has fewer days.</td></tr><tr><td>DATE</td><td>DATE(year,month,day)<br />Creates a date from a year, month and day.</td></tr><tr><td>DATETIMEVALUE</td><td>DATETIMEVALUE(expression)<br />Returns a year, month, day and GMT time value.</td></tr><tr><td>DATEVALUE</td><td>DATEVALUE(expression)<br />Creates a date from its datetime or text representation.</td></tr><tr><td>DAY</td><td>DAY(date)<br />Returns the day of the month, a number between 1 and 31.</td></tr><tr><td>DAYOFYEAR</td><td>DAYOFYEAR(date)<br />Return the day of the calendar year (from 1-366).</td></tr><tr><td>FORMATDURATION</td><td>FORMATDURATION(numSeconds\[, includeDays] | dateTime/time, dateTime/time)<br />Format the number of seconds with optional days, or the difference between times or dateTimes as HH:MI:SS.</td></tr><tr><td>FROMUNIXTIME</td><td>FROMUNIXTIME(number)<br />Return the datetime that represents the given number as the seconds elapsed since 1 Jan 1970.</td></tr><tr><td>HOUR</td><td>HOUR(expression)<br />Returns hour of day.</td></tr><tr><td>ISOWEEK</td><td>ISOWEEK(date)<br />Return the ISO 8601 week number for the given date (from 1-53) so that the first week starts on monday.</td></tr><tr><td>ISOYEAR</td><td>ISOYEAR(date)<br />Return the ISO 8601 week-numbering 4-digit year for the given date so that the first day is a monday.</td></tr><tr><td>MILLISECOND</td><td>MILLISECOND(expression)<br />Returns millisecond of day.</td></tr><tr><td>MINUTE</td><td>MINUTE(expression)<br />Returns minute of day.</td></tr><tr><td>MONTH</td><td>MONTH(date)<br />Returns the month, a number between 1 (January) and 12 (December).</td></tr><tr><td>NOW</td><td>NOW()<br />Returns a datetime representing the current moment.</td></tr><tr><td>SECOND</td><td>SECOND(expression)<br />Returns second of day.</td></tr><tr><td>TIMENOW</td><td>TIMENOW()<br />Returns a time representing the current moment.</td></tr><tr><td>TIMEVALUE</td><td>TIMEVALUE(expression)<br />Returns a time.</td></tr><tr><td>TODAY</td><td>TODAY()<br />Returns the current date.</td></tr><tr><td>UNIXTIMESTAMP</td><td>UNIXTIMESTAMP(date/time)<br />Return the number of seconds since 1 Jan 1970 for the given date, or number of seconds in the day for a time.</td></tr><tr><td>WEEKDAY</td><td>WEEKDAY(date)<br />Return the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday.</td></tr><tr><td>YEAR</td><td>YEAR(date)<br />Returns the year of a date, a number between 1900 and 9999.</td></tr></tbody></table>

* **Logical**

<table><thead><tr><th width="203">Function Name</th><th>Syntax and Description</th></tr></thead><tbody><tr><td>AND</td><td>AND(logical1,logical2,...)<br />Add the num months to the date, using the last date of the month if date is the last day of the month or adding num months has fewer days.</td></tr><tr><td>BLANKVALUE</td><td>BLANKVALUE(expression, substitute\_expression)<br />Checks whether expression is blank and returns substitute\_expression if it is blank. If expression is not blank, returns the original expression value.</td></tr><tr><td>CASE</td><td>CASE(expression, value1, result1, value2, result2,...,else\_result)<br />Checks an expression against a series of values.  If the expression compares equal to any value, the corresponding result is returned. If it is not equal to any of the values, the else-result is returned.</td></tr><tr><td>IF</td><td>IF (logical\_test, value\_if\_true, value\_if\_false)<br />Checks whether a condition is true, and returns one value if TRUE and another value if FALSE.</td></tr><tr><td>ISBLANK</td><td>ISBLANK(expression)<br />Checks whether an expression is blank and returns TRUE or FALSE.</td></tr><tr><td>ISNULL</td><td>ISNULL(expression)<br />Checks whether an expression is null and returns TRUE or FALSE.</td></tr><tr><td>ISNUMBER</td><td>ISNUMBER(Text)<br />Returns TRUE if the text value is a number. Otherwise, it returns FALSE.</td></tr><tr><td>NOT</td><td>NOT(logical)<br />Changes FALSE to TRUE or TRUE to FALSE.</td></tr><tr><td>NULLVALUE</td><td>NULLVALUE (expression, substitute\_expression)<br />Checks whether expression is null and returns substitute\_expression if it is null. If expression is not null, returns the original expression value.</td></tr><tr><td>OR</td><td>OR(logical1,logical2,...)<br />Checks whether any of the arguments are true and returns TRUE or FALSE. Returns FALSE only if all arguments are false.</td></tr></tbody></table>

* **Math**

<table><thead><tr><th width="203">Function Name</th><th>Syntax and Description</th></tr></thead><tbody><tr><td>ABS</td><td>ABS(number)<br />Returns the absolute value of a number, a number without its sign.</td></tr><tr><td>ACOS</td><td>ACOS(number)<br />Returns the arc cosine of the number in radians, if the given number is between -1 and 1. Otherwise NULL.</td></tr><tr><td>ASIN</td><td>ASIN(number)<br />Returns the arc sine of the number in radians, if the given number is between -1 and 1. Otherwise NULL.</td></tr><tr><td>ATAN</td><td>ATAN(number)<br />Returns the arc tangent of the number in radians.</td></tr><tr><td>ATAN2</td><td>ATAN2(y, x)<br />Returns the arc tangent of the quotient of y and x in radians.</td></tr><tr><td>CEILING</td><td>CEILING(number)<br />Rounds a number up to the nearest integer, away from zero if negative.</td></tr><tr><td>COS</td><td>COS(number)<br />Returns the cosine of the number, where the number given in radians.</td></tr><tr><td>EXP</td><td>EXP(number)<br />Returns e raised to the power of a given number.</td></tr><tr><td>FLOOR</td><td>FLOOR(number)<br />Rounds a number down, towards zero to the nearest integer.</td></tr><tr><td>LN</td><td>LN(number)<br />Returns the natural logarithm of a number.</td></tr><tr><td>LOG</td><td>LOG(number)<br />Returns the base 10 logarithm of n.</td></tr><tr><td>MAX</td><td>MAX(number,number,...)<br />Returns the greatest of all the arguments.</td></tr><tr><td>MCEILING</td><td>MCEILING(number)<br />Rounds a number up to the nearest integer, towards zero if negative.</td></tr><tr><td>MFLOOR</td><td>MFLOOR(number)<br />Rounds a number down to the nearest integer, away from zero if negative.</td></tr><tr><td>MIN</td><td>MIN(number,number,...)<br />Returns the least of all the arguments.</td></tr><tr><td>MOD</td><td>MOD(number,divisor)<br />Returns the remainder after a number is divided by a divisor.</td></tr><tr><td>PI</td><td>PI()<br />Returns pi.</td></tr><tr><td>ROUND</td><td>ROUND(number,num\_digits)<br />Rounds a number to a specified number of digits.</td></tr><tr><td>SIN</td><td>SIN(number)<br />Returns the sine of the number, where the number given in radians.</td></tr><tr><td>SQRT</td><td>SQRT(number)<br />Returns the positive square root of a number.</td></tr><tr><td>TAN</td><td>TAN(number)<br />Returns the tangent of the number, where the number given in radians.</td></tr><tr><td>TRUNC</td><td>TRUNC(number,num\_digits)<br />Truncates a number to a specified number of digits.</td></tr></tbody></table>

* **Text**

<table><thead><tr><th width="203">Function Name</th><th>Syntax and Description</th></tr></thead><tbody><tr><td>ASCII</td><td>ASCII(text)<br />Return the first character's code point from the given string as a number.</td></tr><tr><td>BEGINS</td><td>BEGINS(text, compare\_text)<br />Checks if text begins with specified characters and returns TRUE if it does. Otherwise returns FALSE.</td></tr><tr><td>BR</td><td>BR()<br />Inserts an HTML break tag in string formulas.</td></tr><tr><td>CASESAFEID</td><td>CASESAFEID(id)<br />Converts a 15-character ID into a case insensitive 18-character ID.</td></tr><tr><td>CHR</td><td>CHR(number)<br />Return a string with the first character's code point as the given number.</td></tr><tr><td>CONTAINS</td><td>CONTAINS(text, compare\_text)<br />Checks if text contains specified characters, and returns TRUE if it does. Otherwise, returns FALSE.</td></tr><tr><td>FIND</td><td>FIND(search\_text, text \[, start\_num])<br />Returns the position of the search\_text string in text.</td></tr><tr><td>HYPERLINK</td><td>HYPERLINK(url, friendly\_name \[, target])<br />Creates a hyperlink.</td></tr><tr><td>IMAGE</td><td>IMAGE(image\_url, alternate\_text \[, height, width])<br />Inserts an image.</td></tr><tr><td>INCLUDES</td><td>INCLUDES(multiselect\_picklist\_field, text\_literal)<br />Determines if any value selected in a multi-select picklist field equals a text literal you specify.</td></tr><tr><td>INITCAP</td><td>INITCAP(text)<br />Return the text as lowercase with first character of each word made uppercase.</td></tr><tr><td>ISPICKVAL</td><td>ISPICKVAL(picklist\_field, text\_literal)<br />Checks whether the value of a picklist field is equal to a string literal.</td></tr><tr><td>LEFT</td><td>LEFT(text, num\_chars)<br />Returns the specified number of characters from the start of a text string.</td></tr><tr><td>LEN</td><td>LEN(text)<br />Returns the number of characters in a text string.</td></tr><tr><td>LOWER</td><td>LOWER(text)<br />Converts all letters in the value to lowercase.</td></tr><tr><td>LPAD</td><td>LPAD(text, padded\_length \[, pad\_string])<br />Pad the left side of the value with spaces or the optional pad string so that the length is padded\_length.</td></tr><tr><td>MID</td><td>MID(text, start\_num, num\_chars)<br />Returns character from the middle of a text string, given a starting position and length.</td></tr><tr><td>PICKLISTCOUNT</td><td>PICKLISTCOUNT(multiselect\_picklist\_field)<br />Returns the number of selected values in a multi-select picklist.</td></tr><tr><td>REVERSE</td><td>REVERSE(text)<br />Returns the text string in reverse order.</td></tr><tr><td>RIGHT</td><td>RIGHT(text, num\_chars)<br />Returns the specified number of characters from the end of a text string.</td></tr><tr><td>RPAD</td><td>RPAD(text, padded\_length \[, pad\_string])<br />Pad the right side of the value with spaces or the optional pad string so that the length is padded\_length.</td></tr><tr><td>SUBSTITUTE</td><td>SUBSTITUTE(text, old\_text, new\_text)<br />Substitutes new\_text for old\_text in a text string. Use SUBSTITUTE when you want to replace specific text in a text string.</td></tr><tr><td>TEXT</td><td>TEXT(value)<br />Converts a value to text using standard display format.</td></tr><tr><td>TRIM</td><td>TRIM(text)<br />Removes all spaces from a text string except for single spaces between words.</td></tr><tr><td>UPPER</td><td>UPPER(text)<br />Converts all letters in the value to uppercase.</td></tr><tr><td>VALUE</td><td>VALUE(text)<br />Converts a text string that represents a number to a number.</td></tr></tbody></table>
