This template calculates the average of the values of a selected field in all sub-tasks of the current work item. Work items with an empty field are excluded from the calculation.
Configuration
To use the Average 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:
%{avg(filterByValue(fieldValue({issue.cfNNNNN}, subtasks()), !=, null))}
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?
This expression calculates the average value of a specific field across all sub-tasks of the current work item. It ignores any sub-tasks where the field is empty.
2. Step-by-step breakdown
Let’s break it down:
-
{issue.cfNNNNN}: This refers to the custom field you chose (replace NNNNN with the actual field ID). -
subtasks(): This function gets all sub-tasks of the current work item. -
fieldValue({issue.cfNNNNN}, subtasks()): This retrieves the value of the chosen field for each sub-task. -
filterByValue(..., !=, null): This filters out any sub-tasks where the field value is empty (null). -
avg(...): This calculates the average of the remaining field values.
3. Examples
Suppose you want to calculate the average "Story Points" for all sub-tasks of a work item, and the field ID for "Story Points" is 12345. The expression would look like:
%{avg(filterByValue(fieldValue({issue.cf12345}, subtasks()), !=, null))}
If your sub-tasks have Story Points values of 3, 5, and (empty), only 3 and 5 are included. The average would be (3 + 5) / 2 = 4.
4. Real-life use cases
-
Sprint Planning: Calculate the average estimate (e.g., Story Points) for all sub-tasks to understand the typical effort required.
-
Quality Control: Find the average score or rating from sub-tasks (like test results or review scores).