Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,728
Community Members
 
Community Events
184
Community Groups

JQL Query to retrieve User Stories with Time spent on them, or subtasks

Nicolas Mattenet
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!
May 10, 2023

Hi, 

I'm looking for a queries that can return the user stories on my backlog that are DONE with some criteria, and on whom time have been spend (either on the user story itself, or one of it subtask)

 

I have a query that works fine, as long as I don't have to look for timespent on subtasks : 
project in ("<MyProject>")
AND status in (Closed, Done, Built)
AND "Story Points" > 0
AND labels = label1
AND labels = label2
AND timespent > 0

 

But devs in my team also log time on subtasks, and sometimes not the user story itself.
I tried this :

project in ("<MyProject>")
AND status in (Closed, Done, Built)
AND "Story Points" > 0
AND labels = label1
AND labels = label2
AND ( timespent > 0 OR issueFunction in subtasksOf("timespent > 0"))

 

No JQL errors, but didn't work. I can't find any issue. Do you have an idea ?

Thank you very much

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

I think this will work

project in ("<MyProject>")
AND status in (Closed, Done, Built)
AND "Story Points" > 0
AND labels = label1
AND labels = label2
AND issuetype not in sutaskIssueTypes()
AND (
timespent > 0 OR (
issueFunction in subtasksOf("project in ("<MyProject>")
AND status in (Closed, Done, Built)
AND "Story Points" > 0
AND labels = label1
AND labels = label2"
AND timespent > 0))
)
)

 

Breaking it down, the first part will get all the non-subtasks that have story points and non-zero timespent:

project in ("<MyProject>")
AND status in (Closed, Done, Built)
AND "Story Points" > 0
AND labels = label1
AND labels = label2
AND issuetype not in subtaskIssueTypes()
AND (
timespent > 0

 

The second part takes the non-subtask issues retrieved in the first part and selects just the ones that have non-zero timespent

AND (
timespent > 0

So, at that point you have all the non-subtask issues with non-zero time spent.

 

The third part uses the first part (all non-subtask issues, whether they have timespent or not) and gets the subtasks of those issues, but just the subtasks that have non-zero timespent.

               OR ( 
issueFunction in subtasksOf("project in ("<MyProject>")
AND status in (Closed, Done, Built)
AND "Story Points" > 0
AND labels = label1
AND labels = label2"
AND timespent > 0))
)

Suggest an answer

Log in or Sign up to answer