I need help in configuring JQL Query

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 vote

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

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

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)

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

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?

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

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)

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.

Hi Thanks a lot - it is working! Naama

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

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

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

98 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you