Formulas in a grid
This page describes formulas functionality in the Table Grid Editor for Jira Cloud.Â
A Formula is a separate column type based on JavaScript. Add a separate column using formula column type, input formula inside embedded JavaScript Ace Editor and get results on the grid. The grid can process formula logic and aggregate formula results.
Formula column type
You can add a formula as a separate column in a grid by selecting the formula column type. The column uses JavaScript to create formulas.Â
Formula expressions - editor, where you can input JavaScript formula code. It uses Ace Editor, which highlights the syntax.
Error types in the formula column type
You can get the error as a result of the formula execution using following error types:
#error - syntax error
#type operation error - operation could not be executed using different column types.
Formulas as an aggregation function
You can use formula as an aggregation operation in other columns.
It provides you the flexibility to operate grid data in different ways.Â
This feature is available for all column types, supported by the Table Grid Next Generation for Jira Cloud.
Formula expressions
In order to display formula result in the grid column input JS expression in the formula expression configuration.
You can do following operations using formulas:Â
string concatenation;
mathematical operations with numbers: addition, subtraction, multiplication, division;Â
date subtraction - it's possible to use Moments.js library;
conditions
userlist operation
Formula syntax
You can create a formula using JavaScript. The formula can calculate both columns with values inside and other columns that have empty values.
To run the formula when columns have empty values check the checkbox in the column configuration as below.
If you want to make the column values searchable - enable the Index data checkbox.
You can create a formula using JavaScript. The column ID is a variable, use it in the following format:Â $(yourColumnId).
Use return as a keyword to get the formula result.
Userlist in formula
Use the following example to display Userlist column type in the formula
String concatenation
return $(firstStringColumnId) + ' ' + $(secondStringColumnId);
Numbers operations
//Numbers and Integer column type
return $(numb1) * $(numb2) return $(numb1) / $(numb2) return $(numb1) + $(numb2) return $(numb1) - $(numb2) return Math.abs()
Checkbox condition
if($(check) || $(role) === 'Team lead'){ return $(numb1) * $(numb2) } else { return $(numb1) / $(numb2) / 0 }
Using variables with date and moment.js library
Examples
Below you can find formula examples with most common expressions.
Condition with numbers
This example shows how to provide exam results, based on the conditions specified in the formula. You can use conditions in the formula with all available column types.
Condition formula expression
Date subtraction
This example shows how to subtract Date. You can use Date, Time, DateTime column types.
Date subtraction using Moments.js formula expression
Checkbox
This example shows how to use checkbox column type in condition formula.Â
Checkbox formula expression
Numbers
This example shows how to use JavaScript Math.Â
Numbers using JS Math operations formula expression
String concatenation
This example shows how to concatenate string column type.Â