How can I find issues with a label NOT in a specified list?

Mitchell Yawitz December 1, 2017

We are trying to clean up the labels used on a project; I would like to find a way to see a list of issues that have a label that is NOT in a set of labels that I specify.

For example, I want to find all issues that have any label that is not one or more of (foo, bar). Some issues might have 2 labels, such as (foo, zing). I need to find all issues that contains any label that is not foo or bar.

2 answers

0 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.
December 2, 2017

I think you'll need to name the list explicitly, one clause at a time.

labels != foo AND labels != zing AND labels != bar AND ....

Mitchell Yawitz December 2, 2017

Thanks, but that doesn't work either. In this case, it won't find an issue with (foo, zing) because the labels comparison, apparently, matches ANY label on a task. Here, if I want to find any issue with zing, but filter on (labels != foo AND labels != bar), an issue containing foo will cause the AND construct to return FALSE. (By Jira's behavior, labels does = foo.)

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.
December 2, 2017

Hang on, that's not what you asked for.

"I want to find all issues that have any label that is not one or more of (foo, bar)"

The search "label != foo and label != bar" will exclude those, and all you need to do then is add "and label is not empty".  That will answer the question presented.

Or is the original question not quite right?

Mitchell Yawitz December 2, 2017

Thanks for circling back, but I'm not quite sure how else to frame the question.

At a high level, I want to find a list of issues that contain any label not in a list of "approved" labels. In my example, I want to find any issue that contains any label other than "foo" or "bar", but I won't know what "unapproved" labels someone might have entered. If someone applied the "zing" label, I need to find it. (Logically, I need to express "issue has any_label NOT one of [foo, bar]".)

With your suggested test, it won't find (foo, zing), since it will fail the "label != foo" comparison.

Does this clarification help?

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.
December 2, 2017

Ah, yes, I think it explains what I was not getting.

You don't care if foo or bar are on the issue, you want to find issues that have a label other than foo or bar.

In Jira terms, the starting point is "labels is not empty".  But then you want to exclude issues where the labels are only foo, bar or foo and bar.

I can't think of a neat way to to that, because the logic of "not" means you get "not <statement>" not "not <isolated statement>"

Mitchell Yawitz December 2, 2017

Yup, that's it.

I'm beginning to suspect what I want to accomplish isn't possible using JQL.

Someone suggested doing an export of the issue list, and running a script over that, to find the issues that contain "unapproved" labels. That's my last resort. If anyone else has any other outside-the-box solutions for my use case, that would be most appreciated.

0 votes
Alexey Matveev
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.
December 1, 2017

Hello,

You would need to write a JQL like that

labels not in (foo,zing)

Mitchell Yawitz December 2, 2017

Thanks, tried that, but it doesn't work. In your example, it wouldn't find an issue with (foo, zing), since its "foo" label matches--it is in (foo, zing).

Suggest an answer

Log in or Sign up to answer