I need help in configuring JQL Query

Naama Lev
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.
November 24, 2015

Hi Experts, 

I need help in configuring JQL query

Below is my Query,

In the results i would like to receive all issues from IMMI Project or issues labeled with 'IMMI' that are not labeled with BAU. Additionally I don't want to receive Test, "Project Issue", "Project Risk" issue types

My problem is: i don't receive Issues from the 'IMMI Project' that are not labeled with IMMI

(project = "IMMI Project" OR labels = IMMI) AND Type not in (Test, "Project Issue", "Project Risk") and labels != bau  ORDER BY created DESC

Can you please help me understand why? and what should be the correct query?

Thanks

Naama

2 answers

1 accepted

0 votes
Answer accepted
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.
November 24, 2015

When in doubt,

  • simplify the query,
  • question the requirement,
  • question the data as well as the query,

So:

  • The query does look kind of correct to me, and there's not much simplification to do - I'd experiment with removing the "type" clause to see if that makes a difference, but I don't really think it will.  I'd also try each clause individually to ensure they do exactly what I expect.
  • Often, questioning the requirement isn't helpful as the requirements are simple.  In this case, though, the way English works leaves your requirements with two interpretations - "all issues from IMMI or issues labelled with IMMI that are not labelled BAU".  That could come out as "Project = immi or (label = immi and label != bau)", or "(Project = immi or label = immi) and label != bau".  You've built your query for the second, so that's what I'm assuming.
  • Which leads me to data - the simple question there is are you sure you have at least one issue that matches this query?  Could you try just ( project = immi and labels != bau ) ? Check you get a good swathe and then add the "not issue types" clause and check you get something out
Naama Lev
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.
November 24, 2015

Hi @Nic Brough [Adaptavist] Thanks for your answer I know that i have the data to much this filter. When I query (project = "IMMI Project" OR labels = IMMI) AND Type not in (Test, "Project Issue", "Project Risk") I get all the issues from immi project and all the ones that are labeled with IMMI (from the relevant types) Only when i add != BAU, i get only the ones that are labeled with IMMI Can you please advise? Thanks Naama

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.
November 24, 2015

Ok, great testing, it eliminates some problems. Next thing to try is labels = immi and labels != bau If that does what you expect, then I think there's something odd with your (), although I can't see what. So I'd then try (labels = immi and labels != bau) or (project = immi and labels != bau)

Naama Lev
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.
November 24, 2015

Hi, Tried the followings (still i don't get IMMI project issue with no IMMI label) : ((project = "IMMI Project" and labels != bau ) OR labels = IMMI) AND Type not in (Test, "Project Issue", "Project Risk") and labels != bau ORDER BY created DESC ((labels = immi and labels != bau) or (project = immi and labels != bau)) AND Type not in (Test, "Project Issue", "Project Risk") and labels != bau ORDER BY created DESC -------- When I have run labels = immi AND labels != bau AND Type not in (Test, "Project Issue", "Project Risk") AND status != closed ORDER BY created DESC, status DESC, key ASC I got less results - when i checked the difference i saw that my first query receive issues from the project 'IMMI' only if they have any label - but when the label is empty it is not Can you please advise? Thanks Naama

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.
November 24, 2015

I need you to simplify - stop adding clauses and look at the absolute basics. What do you get from the two simple searches I gave earlier? Specifically, does the first one return *any* issues which have both IMMI and BAU as labels?

Naama Lev
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.
November 24, 2015

Hi Query: labels = immi and labels != bau Result: Issues that are labeled with 'IMMI' and not with 'BAU' Query:(labels = immi and labels != bau) or (project = immi and labels != bau) Result: Issues that are labeled with 'IMMI' and not with 'BAU' BUT no issues from the project IMMI that has no label at all Can you please advise? Thanks Naama

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.
November 24, 2015

Ok, I have it. I am really sorry I have not been grasping the problem as quickly as I should have. I don't think I'd have got there without the simplification, and I certainly wouldn't have got it without your patience. There is nothing wrong with the first simple query, it's doing what you expect. The second query has a flaw though, one which is not obvious. The clause "labels != bau" assumes labels has a value, and hence excludes issues with null values. To tell you that a label is *not* BAU, it has to read all the labels on the issue. When there are no labels to check, it can't logically tell you that there isn't a BAU, so it can't give you a result! So... try this query: (labels = immi and labels != bau) or (project = immi and labels != bau) or (project = immi and labels is empty)

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.
November 24, 2015

p.s. yes, there's a lot of negatives in there, and it's not intuitive for us humans, as we don't usually think that there is a difference between null and none/0.

Naama Lev
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.
November 24, 2015

Hi Thanks a lot - it is working! Naama

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.
November 24, 2015

Excellent! Sorry it took me so long to pick up the exact question and spot the actual problem!

0 votes
James Strangeway
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.
November 24, 2015

Try grouping the or clause and the and clause with parenthesis. 

Suggest an answer

Log in or Sign up to answer