Breadcrumbs

Sum of time spent of epic and work items under it

📚

Return the sum of the worklogs of an epic and the work items under it in hours.

Configuration

Create a Custom smart number field and use the General parsing mode.

Expression

%{%{issue.issueType} = "Epic" ? (sum(append(fieldValue({issue.timeSpent}, 
issuesUnderEpic()), [{issue.timeSpent}] ))/ 60) : null}

If the resulting number from the expression contains too many decimal numbers, feel free to select one of the available display formats or to configure it manually.

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 hours) on an epic and all the work items (such as tasks or stories) that belong to that epic.

2. Step-by-step breakdown

Let’s break it down:

  • %{ ... }: This is used to interpret the elements within as part of an advanced expression.

  • {issue.issueType} = "Epic" ? ... : null: Checks if the current work item is an epic. If the work item is an epic, the calculation is performed; otherwise, the result is null (“None”).

  • issuesUnderEpic(): Retrieves all work items that are linked to the current epic.

  • fieldValue({issue.timeSpent}, issuesUnderEpic()): For each work item under the epic, gets the value of the "time spent" field (logged work time, in minutes).

  • append(..., [{issue.timeSpent}]): Adds the epic’s own "time spent" value to the list of its child work items’ time spent values.

  • sum(...): Adds up all the time spent values (from the epic and its child work items).

  • / 60: Converts the total from minutes to hours.

3. Examples

  • If an epic has 3 work items under it, and the time spent values are:

    • Epic: 120 minutes

    • Work item 1: 60 minutes

    • Work item 2: 90 minutes

    • Work item 3: 30 minutes

    The calculation would be:

    • Total minutes = 120 + 60 + 90 + 30 = 300 minutes

    • Total hours = 300 / 60 = 5 hours

  • If the work item is not an epic, the field will show “None”.

4. Real-life use cases

  • Project tracking: Project managers can quickly see the total time spent on an epic, including all related work items, without manually adding up each entry.

  • Reporting: Useful for generating reports on how much effort has gone into a feature or initiative represented by an epic.

  • Resource planning: Helps teams understand where most of their time is being spent and identify large or complex epics.