Filtering labels is returning 0 issues
Asked by Some Guy:

Hi Community,

I try to find within one filter all issues with matches multiple criteria

a) If I search for

```
Project = XYZ AND NOT (labels = AAA AND labels = BBB AND labels = CCC)
```

I get some results

b) If I search for

```
Project = XYZ AND ((labels NOT IN (AAA, DDD)) OR (labels IS EMPTY))
```

I get 0 results, which is fine

c) But when I combine these two:

```
Project = XYZ AND 
((
(labels NOT IN (AAA,DDD)) 
OR 
(labels IS EMPTY)) 
OR NOT (labels = AAA AND labels = BBB AND labels = CCC)
)
```

I also get 0 results, but it should be 20ish like in a)

I tried multiple combinations of brackets, switching to "OR (labels != AND...)" but it just does not work.

Anyone have a solution?

Thanks


Answers:
author: Some Guy
body: First of all, thanks for your replies.

My query is a lot more complex and comprehensive than this example above.

I found an issue at another point in my query, but not it is working.

The suggestion with

```
NOT IN (AAA,BBB)
```

does not work. If it would have worked, I would have used it.

I have a particular project which has 3 labels, that should match, but only if one of the 3 labels is present. That's what I wanted to achieve, among other things, in one query:

```
(((labels NOT IN (AAA, DDD)) 
 OR 
(labels IS EMPTY))
 OR 
(labels = AAA AND (labels != AAA AND labels != BBB AND labels != CCC)))
```

This is finding all tickets, which have not labels AAA or DDD

Also all empty labeled tickets

and all tickets with labels AAA but not AAA+BBB+CCC

I even pushed it to the limit and added 2 more conditions to this one particular sub-query, which is well performing, not like I did it before with sub-filters.

Maybe this thread will help someone someday.

Have a good one


author: Pears Whims
body: Hi [@some guy](/t5/user/viewprofilepage/user-id/1154989),

Let's break down what your query is doing:

```
labels NOT IN (AAA, DDD)
```

This part excludes any issues that have labels AAA or DDD.

```
labels IS EMPTY:
```

This part includes any issues that have no labels at all.

```
NOT (labels IN (AAA, BBB, CCC))
```

This ensures issues with the specific combination of labels AAA, BBB, and CCC are excluded.

Effectively, it seems like your query might be excluding all labels except for the empty ones.

When this gets combined with other conditions using AND, it can be like multiplying by 0. Anything You multiply by 0 (results of AND) - results in 0, i.e. resulting in no results.

**Important Points**

The part where you use labels = AAA is very tricky.

This will only filter issues that have the exact label AAA and nothing else (no other labels).

It's generally easier and more reliable to use labels IN (AAA) or labels NOT IN (AAA), which will include or exclude issues that may have AAA among other labels.

**In case issue remains**

In case this doesn't help.

Could you please clarify exactly what you need with the labels AAA, BBB, and CCC? I'd be happy to help further if you can specify what you're trying to achieve.

In the meantime, I also recommend playing around with the filters - i.e. make changes and saving your progress as you troubleshoot the case.

This can make it easier to backtrack or refine your query as needed.

Best of luck,  
Pears

comments: author: Some Guy
body: > **Important Points**
>
> The part where you use labels = AAA is very tricky.
>
> This will only filter issues that have the exact label AAA and nothing else (no other labels).
>
> It's generally easier and more reliable to use labels IN (AAA) or labels NOT IN (AAA), which will include or exclude issues that may have AAA among other labels.

Thats exaclty, what I wanted to avoid, to find other tickets, which might have AAA among other labels, I want explicitly all tickets \<see condition above\>.


author: karim -Atlassway-
body: Hi [@Some Guy](/t5/user/viewprofilepage/user-id/4750180) ,

It's usually simpler and more trustworthy to apply labels using IN (your_label) or NOT IN (your_label), as this approach will either incorporate or omit issues that could contain AAA along with other labels.  
Otherwise try out [Colored Label Manager](https://marketplace.atlassian.com/apps/1232559/colored-label-manager-for-jira?hosting=cloud&tab=overview) , , there's absolutely no coding required and certainly no need to learn Jira Query Language (JQL) for that matter.

![](https://marketplace.atlassian.com/files/928ca03d-e117-4881-b28c-1e56b7549e34?fileType=image&mode=full-fit)

Atlassway

Karim

comments: author: Some Guy
body: Problem is, that I am no admin and cannot install any plugin


author: Pasam Venkateshwarrao
body: Hi [@Some Guy](/t5/user/viewprofilepage/user-id/4750180)

Welcome to the community,Based on your query i understood that you want the issues which are not in the particular labels right.

you can try with this JQL i have tried it works so that iam sharing with you.

project = ABC AND labels NOT IN ("Label", USER_Group) ORDER BY created DESC


Tags: jira-unknown-hosting-type

jql

labels

query

unknown-hosting-type