Sum field values in sub-tasks

📚

This template calculates the sum of the values of a selected field in all sub-tasks of the current work item.

Configuration

To use the Sum field values in sub-tasks template, simply select it from the template grid. Filter by Sub-tasks to find it faster.

Parameters

To complete the configuration, select a field for the required parameter.

Expert mode

If you switch to Expert mode you can see the Smart field in the Expression Parser. You can now tweak the expression to create a custom smart field based on this template.

Expression

General expression:

%{sum(fieldValue({issue.cfNNNNN}, subtasks()))}

NNNNN is the ID of the custom field you chose for the “Field” parameter.

Display as

Number

Formatting style

###,###.##

Used parser functions

The links lead to the JWTC documentation because the parser functions are shared functionalities.

Details

1. What does the expression do?

The expression calculates the total (sum) of a specific field’s values across all sub-tasks of the current work item.

2. Step-by-step breakdown

Let’s break it down:

  • subtasks(): This function retrieves all sub-tasks that belong to the current work item.

  • fieldValue({issue.cfNNNNN}, subtasks()): For each sub-task, this function gets the value of a specific custom field. The {issue.cfNNNNN} part refers to the custom field you select (replace NNNNN with the actual field ID).

  • sum(...): This function adds up all the values retrieved from the previous step, giving you the total sum.

3. Examples

Suppose you have a work item with three sub-tasks, and you want to sum the values of a custom field called "Trucks needed" (field ID: 12345):

  • Sub-task 1: Trucks needed = 2

  • Sub-task 2: Trucks needed = 3

  • Sub-task 3: Trucks needed = 5

The expression would look like:

%{sum(fieldValue({issue.cf12345}, subtasks()))}

The result would be 2 + 3 + 5 = 10.

4. Real-life use cases

  • Summing up costs or story points from all sub-tasks to display on the parent work item.