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

This widget could not be displayed.

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.

This widget could not be displayed.
Steven Behnke Community Champion Nov 13, 2017

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

This widget could not be displayed.

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 Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

199 views 1 3
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