Filter issuess with multiple labels on with JQL

Fer
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!
February 2, 2021

Hey Folks!

I have been searching for a way to JQL a query which will list all issues with MORE than one label added to it.

I cant find a way.

I know how to filter issues with the labels I want, for instance label = something but what if I want a list of issues that have more than 1 label. I got like 30 labels.

Any guidance is much appreciated!

Thanks!!!

I am on JIRA 8.5.4 btw

3 answers

1 accepted

5 votes
Answer accepted
Clark Everson
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2021

Hi @Fer ,

 

Welcome to the community! Using JQL you wouldn't be able to do this generically (i.e. label is x and ahs more than 1 label) . Label's is not a numerical field and the entire field is global, so if you want to do it you want have to make the filter pairs

lets say you had Label A, Label B, Label C

You would need to do a JQL for the combos

so

(labels = Label A AND labels = Label B AND labels = Label C) OR (labels = Label A AND labels = Label B) OR (labels = Label A  AND labels = Label C) OR (labels = Label B AND labels = Label C) etc

 

Otherwise you would need to do a database search, from the database itself or via tool like scriptrunner

Fer
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!
February 2, 2021

Oh thanks so much for your detailed response! This is great.

Well, due to the ammount of labels I got (around 30) I believe I wont be able to apply the pair solution. I will check scriptrunner! Thanks!!

Jaspreet Singh
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!
February 29, 2024

3 years later and this answer is still helping.  Thank you for your detailed answer.

2 votes
Matthis Thorade July 8, 2022

I used the following with 4 labels, slightly shorter than the above:

 

project=XYZ AND (
(labels=A AND labels in (B,C,D)) OR
(labels=B AND labels in (A,C,D)) OR
(labels=C AND labels in (A,B,D)) OR
(labels=D AND labels in (A,B,C)) )
Asma Rkaya
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!
July 29, 2022

Hi there, I tried this and it worked very well : 

project = XYZ AND labels in (label1, label2, label3) 

Matthis Thorade August 15, 2022

Hi Asma,

the original question was how to find issues with more than one label, but your solution will also return issues that have just one label out of the entire list within the parantheses.

In my case for example, the labels would be for teams or departments: dept1, dept2, dept3, and I want to find all issues where more than one department is involved and show them during a cross-department meeting.

Like Jesse Morales likes this
Anup November 29, 2022

Hi,

I am trying with multiple labels and it is not working. If I keep label=Feedback, it works but not with multiple labels. Pls help

project = ABC AND labels in (Feedback, Process Change, Engagement) AND status not in (Completed, Done, Cancelled) ORDER BY Summary ASC, updatedDate DESC

Matthis Thorade November 29, 2022

This seems to be unrelated to the original question, you want to find a single label, while the original question was to filter tickets that have more than one label. The filter should only return tickets that have two or more labels, but not tickets with just one label.

Anup November 30, 2022

Yes, but I am looking for solution. If someone can help, I can use it.

Matthis Thorade November 30, 2022

"Process Change" needs the quotes, because it has whitespace. 

You should build up your queries step by step, and make sure they get the green checkmark. Use Autocomplete! 

0 votes
John Bevan March 15, 2023

You can use JQL/Advanced Query to filter for all cases where your field is not empty.

Then you can use the `Export` option to extract that to CSV

Once you've got a CSV you'll find that fields which can contain multiple values appear multiple times (e.g. `Labels`, or any `Custom Field (MyMultiSelect)`).  The first of these columns will contain a value (you've already filtered out those which didn't have anything via the JQL).  Those with more than one value will also have something in the second of these columns; whilst those with only one value will have a blank - so you can now filter values in Excel/PowerShell/whatever you use to work with CSVs - to find those with multiple values.

 

If you needed to go back to JQL with your findings (e.g. to use `bulk update`) you could generate a new JQL query which filters on the keys you found:

- Filter for those rows with multiple labels (or for those without, per your needs)

- Copy these to a new sheet (or else delete these rows if you're interested in the inverse) so you have a table with just the items you're interested in

- Create a new column with formula `=concat(B2,",")` (assuming B is your key column) to get the key followed by a comma.  Copy this formula across all rows in your table

- In another blank cell put `=concat("key in (",concat(X:X),")")` (where X is the new column created in the previous step.  This will create your JQL with all the keys you're after

- Copy/paste this value into your JQL filter.

 

The above's not dynamic - it'll only give you a list of keys for a static filter.

If you want something more dynamic another approach could be to use the CSV results to identify common pairs - so you can use the pairs workaround above, but instead of working out every possible combination you use the data to work out the most likely combos and then only hunt for those; giving you a dynamic filter that will catch most things.

 

Not a great solution, but hopefully helpful where you've got a lot of options making the "pairs" workaround above impractical.

Suggest an answer

Log in or Sign up to answer