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,559,660
Community Members
 
Community Events
185
Community Groups

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.

 

6 answers

2 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 13, 2017

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 14, 2017

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

I came across this thread and eventually came up with another solution for anyone still interested. What I did was create a separate structure (XYZ) that pulls the data I want to filter through. Then I add a Filter by Attribute according to exactly the labels I am interested in. 

Then in the search section, I type in a JQL query issue in structure("XYZ"). Then save and now I have a saved filter showing only the labels I want. This workaround will be useful for people who don't have administrative permissions and cannot create new fields like me. Although I believe this uses the scriptrunner extension.

I use

labels = LabelA AND !labels = LabelB AND !labels = LabelC AND !labels = LabelD

 

! = NOT

 

For me this returns tickets with labels on LabelA but not LabelC or LabelD

Hi,

Whatever I do, the labels don't show any results in the search. What could be the issue.

 

Regards,

Amna

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 20, 2022

That sounds like you have not added the column for labels to the issue navigator output?

Is it possible to do that in cloud jira without functions and additional plugins?

Steven Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 15, 2018

No. Jira does not offer this function out-of-the-box. You should consider using a custom field instead of labels.

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.

0 votes
Steven Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 13, 2017

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

Suggest an answer

Log in or Sign up to answer