Filter issues that have only one specific label and no other labels

We have several labels on issues in my project.
E.g. A, B, C, D, ...

I want to find the issues that have label A and only label A.
That is, I dont want to find any issues having A + another label. Just the ones with A only.

And I dont want to list all other possible labels and exclude them, as in the following query. ( labels=A and labels not in (B,C,D...) )
This is not a good solution when there are a huge amount of other labels.


3 answers

1 votes

Off the shelf, you can't do it.

It is possible with code, and I've seen two approaches before

1.  A field that counts labels - your query becomes "labels = A and 'count of labels' = 1"

2.  A JQL function - your query becomes "labels = A and labelCount() = 1"


Both of these are really easy to implement if you've got ScriptRunner installed, I've done the field one with my own code and SR, and seen SR create the function as well.

Thank you for your answer. I have not worked much with JIRA.

Have I understood you correctly that for 1) I have to create an new field. How do I get this new field to count number of lables?

I dont think we have ScriptRunner installed. I will check with the administrators.

Correct - a scripted field in scriptrunner can be really simple, I suspect it can be done in one line of code for counting labels.

0 votes
Steven Behnke Community Champion Nov 13, 2017

I don't think it's possible to write a query like this out-of-the-box.

I am now trying to use:

issueFunction in issueFieldMatch("", "labels", "^A$")

but that doesnt work... Give no matches at all.

If I instead have:

issueFunction in issueFieldMatch("", "labels", "A")

ist find all issues with label A but also the issues with several labels.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,063 views 13 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot