Sum up worklog for child issues
Curious about the total effort required for the subtasks within a Story or the Stories within your Epic?
Leverage the Advanced Formula field, empowered by Jira Expressions, for seamless calculations without constraints.
Content
The formula
Jira Expressions provide a wealth of functions and properties for retrieving issue data. For instance, you can iterate over all subtasks to fetch field values and aggregate them. Consider the following formula:
issue.subtasks.reduce((result, issue) => result + (issue.timeSpent || 0), 0)
Let’s analyse this step by step
issue.subtasks
Returns a list of all subtasks (find more issue properties here: Jira expressions#issue)reduce(result, issue) => ..., 0)
Helps you to iterate and aggreate values, whereresult
is the sum andissue
a subtask.0
is the initial value of the aggregation (see Jira expressions#data-aggregation)issue.timeSpent || 0
This retrieves the timeSpent Value in seconds (worklog) or if unset returns0
Calculate for Epics
A quite similar formula can be used for child issues of an Epic
Instead of issue.subtasks
you have to write issue.stories
(see Jira expressions#epic)
issue.stories.reduce((result, issue) => result + (issue.timeSpent || 0), 0)
Make sure to only configure the field for Epics.
You may also use a check if the current issue is an Epic: issue.isEpic ? <do epic calculation> : 0