How can you automatically sum the story points of all subtasks?

Eric Lundberg August 8, 2018

I want the Story Points field for the parent story to be the sum of the sub-tasks.

I tried using the {{triggerIssue.Story Points}} + {{issue.Story Points}} option but that continues to add if we adjust.Screen Shot 2018-08-08 at 3.53.22 PM.png

Example:

Subtask A = 12

Subtask B = 10

Story 1 = 22

This is fine so far...

Subtask A: 12 -> 15

Story = 37 (not 25 like it should)

I want it such that whenever I update a sub-task estimate, it queries all subtasks and adds their story points OR if it detects a change, subtracts the previous value, and adds the new value,

 

 

 

11 answers

1 accepted

13 votes
Answer accepted
John McKiernan
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 8, 2018

Hi Eric,

thanks for your message.

You should be able to use {{subtasks.Story Points.join(" + ")}}

Let me know if that doesn't work for you!

Cheers,

John

Eric Lundberg August 8, 2018

It works well, thanks! Where can I find good documentation about that?

Like # people like this
John McKiernan
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 8, 2018

Good to hear! 

We do have some docs around the smart fields here:

https://docs.codebarrel.io/automation/smart-fields/working-with-lists.html

However, truth be told, they are not as comprehensive as we would like.

I am in the process of putting together more detailed docs, vids, and webinars over the next few months. In the meantime, feel free to reach out if you run into any roadblocks! 

Cheers,

John 

Like # people like this
Kavit October 3, 2018

Hi,

I had tried using 

"{{subtasks.timetracking.originalEstimateSeconds.join(' + ')}}"

and 

"{{subtasks.originalEstimateSeconds.join(' + ')}}"

 

but non of above working It shows below error

 

Error while rendering additional fields.Invalid method call syntax

 

and on top of that got one question.

If originalEstimate is in day/min/hrs/week then how It will work?

subtasks.originalEstimate.join(' + ')

 

 

Ged H November 12, 2018

Hi, I just discovered this post.

I've been trying to get story points for an EPIC to sum from multiple Tasks linked using the EPIC link. I've tried the suggestion {{subtasks.Story Points.join(" + ")}} and also used {{issue.Story Points.join(" + ")}}. Using Smart values doesn't appear to work when I JIRA automation rule.. Any suggestions as to why this wouldn't work?

Thanks

Ged 

John McKiernan
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
November 13, 2018

Hi Ged,

At the moment, this isn't possible with Automation for Jira. 

We have an existing improvement issue here which I have added your vote to: https://codebarrel.atlassian.net/browse/AUT-475

If you are new to smart values within automation for jira, here are two good resources to help:

Docs:  https://docs.automationforjira.com/smart-fields/smart-fields.html

Blog: https://docs.automationforjira.com/smart-fields/smart-fields.html

Hope that helps!

Cheers,

John 

Danielle Dunn June 27, 2019

Please add my vote

Like John McKiernan likes this
Niyara Mamontova August 14, 2019

Any updates on this?

JC March 11, 2020

Kavit, i have a response: 

{{#=}}{{#=}}{{subtasks.timetracking.originalEstimateSeconds.join(" + ")}}{{/}}/3600{{/}}

Like Martin_Kleine likes this
Martin_Kleine April 2, 2020

Thanks JC! With following adjustment, I was able to now sum up the estimates of all subtasks.


{
    "fields": {
        "timetracking": {
            "originalEstimate": {{#=}}{{#=}}{{subtasks.timetracking.originalEstimateSeconds.join(" + ")}}{{/}}/60{{/}}
        }
    }
}

Mikaela Bertucci April 7, 2020

UH? as a non techy person I have no idea where this code is supossed to go 

Like Denise.Moraes likes this
Martin_Kleine April 22, 2020

In the Additional Fields text box.

 

See screenshot 

Like Fernando Bittencourt likes this
14 votes
Stefanie Häuser May 12, 2020

By the way, I finally got it to work for me by using this code shared above.

 

{
"fields": {
"Story point estimate": {{#=}}{{subtasks.Story point estimate.join(" + ")}}{{/}}

}
}

 

However, I had to adjust the "Story point estimate" part because we're actually using a custom field called "Story Points" for this for some reason. This took me a while to figure out. In the end what helped me was this article here: https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/ There is a paragraph on "Referencing issue fields" which showed what it needs to look like for custom fields. So in my case the code now actually looks like this:

 

{
     "fields": {
           "customfield_10021": {{#=}}{{subtasks.customfield_10021.join(" + ")}}{{/}}

     }
}

I hope this can also help some other people ;) 

Marina Mendez (Nina) May 12, 2020

You're amazing @Stefanie Häuser !! I've tried so hard to make this work and you help me a lot! Your solution works for me as well!

Thank you very much for share with us :) 

Dominique Brandt May 15, 2020

Thank you SO much @Stefanie Häuser !

I have one further issue - perhaps someone of you has a solution.

In our team, we are using this rule to work more smoothly with Jira. The developers don't have to remember to update the Story Points of a Story when there is change in the subtasks (e. g. new subtasks, other amount of Story Points, etc.)

This rule works perfectly for us als long as we don't have a 'Done' subtask in our story.
The goal is, Subtasks with Status = 'Done' shouldn't be included in the calculation. How can I add this condition into my automation? 

 

You can see my actual try in the screenshot. The result is, that as long as there is a subtask with the status = 'Done', it won't calculate anything (which makes sense in my opinion)

Bildschirmfoto 2020-05-15 um 17.30.52.png


 

Any ideas? :)

Like Akshay Vadher likes this
Brad Christiansen September 13, 2021

@Stefanie Hausner 

I'm getting a JSON error.  any thoughts?

{
"fields": {
"Story point estimate": {{#=}}{{subtasks.Story point estimate.join(" + ")}}{{/}}

}
}

Like Martí Bastida Comas likes this
Brad Christiansen February 23, 2022

@Martí Bastida Comas I was able to resolve my issue with:

When Value changes for story point estimate

if epic exists

for epic (Parent)

then lookup issues:
"Parent"={{issue.key}}


and edit issue fields:
{
"fields":
{
"Story point estimate": {{lookupIssues.customfield_11204.sum}}
}
}

Ultimately, this looks up the parent epic for the task that was just edited and then sums all "story point estimate" fields for any task/ticket that has that epic as a parent and stores the sum in the Epic's story point estimate field.

I don't remember how I came up with custom field #11204 as it's been awhile since I figured it out.  I think I figured it out by doing an advanced export of a search that included that field.  I'd wager there are other ways to find that number.

Hope this helps.

Like Martí Bastida Comas likes this
Martí Bastida Comas February 23, 2022

Wow, really appreaciate it. I will definetly take a look at your solution :)

 

 

PS: I think that never in my life a like in a comment triggered such a fast and informative response ;)

Manish V
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 22, 2024

Thank you very much Stefanie Häuser

You saved hours of my effort. That's exactly what I was looking for.

Best Regards,
Manish

3 votes
M_Y_ August 15, 2020

sorry for necro.

 

For next-gen, {{subtasks.Story Points.join(" + ")}} will not work properly.

Use "Story point estimate" .

{
"fields": {
"Story point estimate": {{#=}} {{subtasks.Story point estimate.join(" + ") }} {{/}}
}
}

or

{
"fields": {
"Story point estimate": {{#=}} {{#subtasks}} {{Story point estimate}} + {{/}} 0 {{/}}
}
}

 

Looks like this

Screen Shot 2020-08-15 at 23.05.04.png

Karthieswari Baskar October 5, 2020

Screenshot 2020-10-05 at 5.16.05 PM.pngDid any one face this issue ?

Like susan hsieh likes this
Rafael Hideaki Teruya May 18, 2021

I did. Did you solve this ?

susan hsieh June 3, 2021

Hi  @Rafael Hideaki Teruya 

I face this issue too.

My project is next-gen Jira software project.

I thought the "story point estimate" is origin create by Jira

because the issue type setting 


 截圖 2021-06-04 上午10.05.57.png

 

Then I find the "Story point estimate" is custom field 


MicrosoftTeams-image.png

 

You can find your customfield id by this tutorial : https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/

 

And I set Additional fields to My project setting id

{
"fields": {
"customfield_10016": {{#=}}{{subtasks.customfield_10016.join(" + ")}}{{/}}

}
}

 

截圖 2021-06-04 上午10.09.51.png

 

It works. :)

Norma Barr November 9, 2021

This finally works, using the smart value, thank you

2 votes
Joaquín April 16, 2020

Hi all!
Perhaps it helps to somebody else. I could sum up the estimates of all subtasks and set it as the estimation of the parent issue. This is the code:

{
"fields": {
"Story point estimate": {{#=}}{{subtasks.Story point estimate.join(" + ")}}{{/}}

}
}

 

Mikaela Bertucci April 22, 2020

Hey there, I thought I'd try your code as the last code I had in wasn't always reliable.  Or maybe it's the trigger itself. It doesn't always fire and sometimes the total is incorrect until I refresh the page. Any thoughts?

Joaquín April 22, 2020

Hey @Mikaela Bertucci , I think that the total is always correct. The problem is what you mentioned: The UI doesn't update automatically after an event is fired, so you need to refresh manually. If sometimes it doesn't fire it could be because of a misconfiguration in your "when" and "if" conditions (they are not part of the code that I uploaded). Or maybe it always fires but you don't notice because you don't see any changes on the UI until the manual refresh.

Stefanie Häuser May 12, 2020

It's not working for me either. It's giving me "Not valid JSON"

Bulat Usmanov May 27, 2021

It works!

1 vote
Stefanie Häuser April 14, 2020

@John McKiernan Hey thanks for those tips! I'm trying to set up this subtask story point automation. I followed your instructions. The audit log tells me that everything worked successfully when I test it. However, the story point field does not get updated. Any ideas why this might be?

 

Screenshot 2020-04-14 at 15.57.05.pngScreenshot 2020-04-14 at 15.57.11.pngScreenshot 2020-04-14 at 15.57.21.pngScreenshot 2020-04-14 at 15.57.36.png

Maria Yacoub April 16, 2020

Hello @John McKiernan1 I have the same problem than @Stefanie Häuser , I am using Next gen project and trying to have "Story points of parent issue  = sum of the story points of child issue". My parent issue is a Story.

 

 Capture du 2020-04-16 12-28-42.png

I tested with {{childissues.Story points.join(" + ")}}  and {{subtasks.Story points.join(" + ")}}.

 

My audit log writes the changes as a success but my field "Story points" in the parent issue isn't updated .

 

Capture du 2020-04-16 12-30-25.png

 

Can you tell us what can be wrong in our rules ?

 

Thank you

Marina Mendez (Nina) May 4, 2020

I have the same problem :( 

JasonB3 July 23, 2020

Next Gen projects use "Story Point Estimates" not "Story Points"

Benson September 17, 2020

@M_Y_ or anyone managed to get sum of standard issue story points into Epic Story Points? If so, please can you share your smart value details.

I also tried the same Smart Values: 

  • {{childissues.Story points.join(" + ")}}
  • {{subtasks.Story points.join(" + ")}}

and the log says success for both but story points aren't updated in the Epic.

Colin Betson January 29, 2021

Hi there, Im desperately trying to achieve the same thing here - sum up of story points to Epic level using automation.  Any further developments on it?

Saket Gune June 22, 2021

I am having the same issue. My rules run without any issues but can not see the story points on the stories. Looking forward for the solution.

Ryan July 26, 2021

I achieved an Epic roll up through a scripted field in Scriptrunner. I created a field called "Aggregate Story Points" and then used this code to get the results I was looking for.  Works really well.


import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor;

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def cfManager = ComponentAccessor.getCustomFieldManager()
double totalSP = 0
customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Story Points");
enableCache = {-> false}

issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->

double SP = (double)(issueLink.destinationObject.getCustomFieldValue(customField) ?: 0)
totalSP = SP + totalSP;
}
return totalSP as Long ?: 0L
Like Mayank Kamra likes this
Gayatri Pawar April 20, 2022

Will it add up all subtasks and stories under it? Like all story points for epic

Mayank Kamra May 8, 2022

yes it will add story points of sub-tasks too!

0 votes
Dilan Fatma Öncevarlık March 6, 2023

Hello everyone,

Is it possible to do the operations you mentioned for tasks, not subtasks?
Instead of using sub-task on the board, we split the tasks into tasks and I cannot automatically save their scores to the story.
I tried {{tasks.Story Points.join(" + ")}} but it didn't work.
You can see my flow in the attachment.

Screenshot at Mar 06 11-43-01.png

0 votes
mohitdixit54 November 7, 2022

Hi there, above codes update the Story point estimation field. If you want to update the Story points field as well then add below code:-

{ "fields": { "Story point estimate": {{#=}}{{subtasks.Story point estimate.join(" + ")}}{{/}} , "Story points": {{#=}}{{subtasks.Story point estimate.join(" + ")}}{{/}} } }

 Jira Automation.png

0 votes
Parvathy Manishanker davey September 7, 2021

In Jira Cloud - I could get the sum of story points of subtasks on the parent story successfully using Smart Value: {{issue.subtasks.Story Points.sum}}. But the only issue is when a sub task is deleted it doesn't recalculate the story points and update the parent story. Any suggestions

Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

@Parvathy Manishanker davey

For this scenario I would run a scheduled rule at midnight that cleans up all the story points.  Take a look at this video and follow rule #3: https://www.youtube.com/watch?v=PROcxEOMyGM&t=13s

You would just needs to update the branches to do it on the Parent task.  

Regards,

Fabian

0 votes
Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 25, 2021

Hi Everyone,

Here is a link to a tutorial on how to sum up subtasks: https://www.youtube.com/watch?v=60sWD66l19k

The key smart value formula is: {{issue.subtasks.Story Points.sum}}

Regards.

Saket Gune June 25, 2021

Thanks Fabian.

I have written the smart value formula on Story point estimate instead of Story Points as we are using Story Point Estimate. If i go to the automation, I see that the automation is running correctly, it is editing the story, and I am also getting emails from Jira Automation showing the correct story points. However, I am not seeing it on the backlog.

Screen Shot 2021-06-25 at 10.36.57 AM.pngScreen Shot 2021-06-25 at 10.37.19 AM.png

 

 

Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 25, 2021

Hi @Saket Gune

You may have to set the board to show Story Points Estimates instead of Story Points then. 

Here are the instructions on how to configure the board: https://support.atlassian.com/jira-software-cloud/docs/configure-estimation-and-tracking/

Saket Gune June 25, 2021

Hi Fabian,

Thanks. I went through the instructions but I can not see Board Settings I am the administrator for the project. I only see Configure Board. Here are my user settings.

Screen Shot 2021-06-25 at 11.47.31 AM.png

 

I also do not see Active Sprint Menu

Screen Shot 2021-06-25 at 11.49.23 AM.png

Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 25, 2021

In your backlog, go to the top right corner:

board_settings.png

 

 

However, I recommend you stick with Story Points because once you start the sprint and complete it, you want to ensure that the reports are tracking the actual story points and not the Story Points estimate.  

Saket Gune June 25, 2021

Thanks, Fabian.

 

I can not see it. Is this feature available for a standard subscription? I am currently on a free subscription.

Saket Gune July 7, 2021

Fabian,

Thanks for all your help. I was able to figure it out. The reason I was not able to see the options is that I was using the incorrect Project type. I was using the team-managed project. I created the new company-managed project and it enabled me to see the screens you had mentioned in your response.

Saket Gune July 8, 2021

Does anyone know why I see two options for Story Points when i am creating the automation?

Screen Shot 2021-07-08 at 9.46.02 AM.png

Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 8, 2021

That usually happens when you have two customfields with the same name.  Check your customfield in the sys admin configurations. 

0 votes
Dominique Brandt May 20, 2020

Hey Guys,

 

I have one further issue - perhaps someone of you has a solution.

This rule of calculating Story Points of subtasks works perfectly for us als long as we don't have a 'Done' subtask in our story.
The goal is, Subtasks with Status = 'Done' shouldn't be included in the calculation. How can I add this condition into my automation? 

 

You can see my actual try in the screenshot. The result is, that as long as there is a subtask with the status = 'Done', it won't calculate anything (which makes sense in my opinion)

Bildschirmfoto 2020-05-15 um 17.30.52.png

 

Any ideas? :)

A_lis February 24, 2022

Hi Dominique,

Does the above solution work for you?

Akshay Vadher May 26, 2022

@Dominique Brandt  did you find any solution?

Brad Christiansen May 26, 2022

AutoSum.png

@Dominique Brandt, @Akshay Vadher, @A_lis 
This solution is working for me to sum the "story point estimate" field of any task with a given epic, when that task's status is not "complete" or "project dropped" and fill in the epic's custom field of "story points remaining".  I'm not sure if it will work out of the box for sub-tasks because I do not use sub-tasks, but I think it will work for any task/story/subtask?  You can also change it to simply look for not "Done".

You will want to update which fields you are summing and updating, but the search for which tasks to sum should be valid for you?

Akshay Vadher May 26, 2022

I want join sub subtasks but only subtasks which are not done

Brad Christiansen May 26, 2022

@Akshay Vadher I assume you mean "sum" when you say "Join"?  If so, you should be able to modify my example at the Lookup Issues section to meet your needs.  you can use status != "Done" and you can even add in a type = subtask (or something similar) if you want to make sure you are ignoring normal tasks and stories that might be part of the epic.

Then you will want to update the Edit Issues portion so that you are summing the correct field (my custom field ID numbers will be different than yours, and you may be able to just use the field names directly).

Hope this gets you going in the right direction.

Akshay Vadher May 26, 2022

That approach worked. Thanks. 

Ree Agarwal July 26, 2022

Hi @Akshay Vadher and @Brad Christiansen 

I am trying to achieve the same thing but using the following 

Automation rule.jpg

Could you help with the query because I am not sure how to use your query with my settings.

0 votes
Mikaela Bertucci April 7, 2020

Uh? as a non techy person.. where is this code supposed to go?

Dilan Fatma Öncevarlık March 6, 2023

Project Settings > Automation
And then you have to create the flow they show in previous comments.
At the last step you can use the code they shared

Like 田嶋 裕_Yu Tajima_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events