Breadcrumbs

Time spent in the current and linked work items

📚

This template displays the sum of the time spent in the current and linked work items.

Configuration

To use the Time spent in the current and linked work items template, simply select it from the template grid. Filter by KPI to find it faster.

Parameters

This template does not require any additional parameter configuration.

Expert mode

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

Expression

General expression:

%{sum(append(fieldValue({issue.timeSpent}, union(linkedIssues(), issueKeysToIssueList(%{issue.key}) )), [0])) / 60}

Display as

Number

Formatting style

Default (unformatted)

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 total time spent in minutes on the current work item and all its linked work items. It adds up the time spent on each, and then converts the result from minutes to hours.

2. Step-by-step breakdown

Let’s break it down:

  • %{issue.timeSpent}: This refers to the time spent on a single work item (measured in minutes).

  • linkedIssues(): This function gets all work items that are linked to the current work item.

  • issueKeysToIssueList(%{issue.key}): This converts the current work item’s key into a list, so it can be processed together with the linked work items.

  • union(linkedIssues(), issueKeysToIssueList(%{issue.key})): This combines the current work item and all its linked work items into one list, ensuring there are no duplicates.

  • fieldValue({issue.timeSpent}, ...): For each work item in the combined list, this retrieves the value of the “Time Spent” field.

  • append(..., [0]): This adds a zero to the list to prevent errors.

  • sum(...): This adds up all the time spent values from the list.

  • / 60: Since time spent is measured in minutes, dividing by 60 converts the total to hours.

3. Examples

  • If the current work item has 20 minutes logged, and it has two linked work items with 10 minutes and 30 minutes logged, the expression will add: 20 + 10 + 30 = 60 minutes. Dividing by 60 gives 1 hour.

  • If there are no linked work items and the current work item has 120 minutes, the result will be 2 hours.

4. Real-life use cases

  • Teams can track the overall effort spent on a feature by summing up the time logged on the main work item and all its linked work items.