Skip to main content

Formulas reference

This reference provides detailed information about the formulas that you can use in your formula fields.

Expression syntax

Formula expressions use a syntax similar to that used by calculators and other mathematical applications.

Operations

Formula and rollup expressions support standard mathematical operations using either operator notation or function notation. Here are the most common operations:

OperationDescriptionOperatorExample expressionResult
AdditionAdd two values+2 + 35
SubtractionSubtract second value from first-5 - 23
MultiplicationMultiply two values*4 * 312
DivisionDivide first value by second/10 / 25

Order of operations

When using operator notation, you can use parentheses to override the default order of operations:

2 + 3 * 4    // = 14 (multiplication happens first)
(2 + 3) * 4 // = 20 (addition happens first)

Variables

Formula expressions can reference some Jira fields as variables. For example, the following formula expression calculates the estimated cost of labour for each row by multiplying the number of hours worked by an average labour cost ($50/hour) defined in the expression:

// Formula expression to calculate the estimated cost of labour
// 'timespent' is the field key for Jira's 'Time Spent' field

timespent * 50

Formula expressions can also reference other formula fields as variables. For example, the following formula expression calculates the estimated cost of labour per Story Point for each row by dividing the estimated cost of labour by the number of Story Points:

// Formula expression to calculate the estimated cost of labour per Story Point
// 'formula_labour_cost' is the field key for the formula field created earlier
// 'customfield_10028' is the field key for Jira's 'Story Points' field in this particular Jira instance

formula_labour_cost / customfield_10028
tip

Formula fields are evaluated in descending order. When referencing other formula fields in a formula expression, make sure the referenced formula fields appear above the current formula field in the list. You may need to reorder your formula fields to ensure the formula expression is evaluated correctly.

Rollup expressions work similarly, but they are evaluated using summary level data instead of row-level data. To reference a variable in a rollup expression, append an aggregation method to the variable name (e.g. .sum, .avg, .min, .max). This determines how the referenced field's values will be summarized when the rollup expression is evaluated. For example, the following rollup expression calculates the estimated cost of labour per Story Point for a group of rows by dividing the total estimated cost of labour by the total number of Story Points:

// Rollup expression to calculate the estimated cost of labour per Story Point
// 'formula_labour_cost' is the field key for the formula field created earlier
// 'customfield_10028' is the field key for Jira's 'Story Points' field in this particular Jira instance

formula_labour_cost.sum / customfield_10028.sum

Learn more about the available expression variables you can use in your formula and rollup expressions.

Available expression variables

To see which fields are available for use in your formula and rollup expressions, click the Available expression variables button.

Formula fields tab with the 'Available expression variables' button hoveredFormula fields tab with the 'Available expression variables' button hovered

A table will be displayed listing all fields that can be used.

Available expression variables table showing supported fieldsAvailable expression variables table showing supported fields
  • To reference a field in a formula expression, use the variable name listed in the Variables column (e.g. timespent).
  • To reference a field in your rollup expression, use the variable name listed in the Variables column and append the appropriate aggregation method (e.g. timespent.sum).
info

The fields reference also provides a non-exhaustive list of supported fields that may be used as expression variables.

Arithmetic functions

Several other arithmetic functions are available:

FunctionDescriptionExample expressionResult
abs(x)Calculate the absolute value of a numberabs(-3)3
ceil(x)Round a number up to the nearest integerceil(4.3)5
floor(x)Round a number down to the nearest integerfloor(4.3)4
round(x)Round a number to the nearest integerround(4.3)4

Complex logic

Formula expressions can be used for more complex logic by combining the basic operations described above with comparison tests, logical tests, and conditionals.

Comparison tests

Formula expressions support the following comparison tests:

TestDescriptionOperatorExample expressionResult
EqualTest whether two values are equal==2 == 3false
UnequalTest whether two values are unequal!=2 != 3true
Smaller thanTest whether the left value is smaller than the right value<2 < 3true
Larger thanTest whether the left value is larger than the right value>2 > 3false
Smaller than or equal toTest whether the left value is smaller than or equal to the right value<=2 <= 3true
Larger than or equal toTest whether the left value is larger than or equal to the right value>=2 >= 3false
warning

Formula fields only return numeric results. The example expressions above will be evaluated correctly but will return empty values if used in isolation. Comparison tests should be used in conjunction with other operations to perform more complex calculations that return a numeric result.

Logical tests

Formula expressions support the following logical tests:

TestDescriptionOperatorExample expressionResult
Logical andTest whether two values are both non-zero/non-emptyand2 and 0false
Logical notTest whether a value is zero/emptynotnot 0true
Logical orTest whether either of two values are non-zero/non-emptyor2 or 0true
Logical xorTest whether exactly one of two values is non-zero/non-emptyxor2 xor 0true
warning

Formula fields only return numeric results. The example expressions above will be evaluated correctly but will return empty values if used in isolation. Logical tests should be used in conjunction with other operations to perform more complex calculations that return a numeric result.

Conditionals

Formula expressions support conditional logic using the ternary operator. For example, the following expression uses the estimated cost of labour (from the example above), but if the estimated cost is less than $150, it returns $150 instead:

// Formula expression to calculate the estimated cost of labour, with a minimum value of $150
// 'formula_labour_cost' is the field key for the 'Estimated cost of labour' formula field created earlier

formula_labour_cost > 150 ? formula_labour_cost : 150

Another example is the following expression, which returns 1 if the Time Spent is greater than the Original Estimate. This formula could be used to report on issues that are over budget (e.g. by configuring a filtering rule that filters for rows where the formula field has a value of 1).

// Formula expression to identify issues that are over budget
// 'timespent' is the field key for Jira's 'Time Spent' field
// 'timeoriginalestimate' is the field key for Jira's 'Original Estimate' field

timespent > timeoriginalestimate ? 1 : 0