Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I have 3 labels in the query but i need only 2 out using JQL?

Mahesh June 12, 2025

Hello Atlassian Community Team, 

I have the following use case, and I need some help.

Use Case: 

We have the following Labels across 5 JIRA stories - Customer-Experience, UAT, Operations, FY26Q1, FY26Q2. 

Story - 1: Customer-Experience, UAT, Operations, FY26Q1, FY26Q2. 

Story - 2: Customer-Experience, UAT, Operations, FY26Q1.

Story - 3: Operations, FY26Q1, FY26Q2. 

Story - 4: UAT, Operations, FY26Q1, FY26Q2. 

Story - 5: Customer-Experience, UAT, Operations, FY26Q1, FY26Q2. 

But I only need Customer-Experience and Operations to show without the other 3 labels being listed. 

I tried following queries, But it does bring out all the results. 

  • project = XXXXX AND issuetype = Story AND status = Done AND (labels IN (Customer-Experience, Operations) AND labels != ("FY26Q1","FY26Q2, "UAT"))
  • project = XXXXX AND issuetype = Bug, Story AND status = Done AND (labels IN (Customer-Experience, Operations) AND labels NOT IN (FY26Q1,FY26Q2, UAT))

Please help with the Query, if not please suggest what other options can be used in this case. 

Thanks, 

Mahesh 

 

1 answer

1 vote
Bill Sheboy
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.
June 12, 2025

Hi @Mahesh -- Welcome to the Atlassian Community!

A JQL expression helps search for work items / issues meeting the criteria.  It does not impact filtering the specific values of fields shown in the results.

 

What problem are you trying to solve by searching for work items containing those two label values but not show all label values?  That is, "why do this?"

Knowing that may help the community to offer better suggestions.

 

Kind regards,
Bill

Mahesh June 12, 2025

Hello @Bill Sheboy 

Thanks for the quick response. 

I am trying to plot a Gadget (Pie Chart) against these 5 stories and I wanted to know how many the Count to show how many are part of Customer Experience and How many are part of Operations. 

Thanks, 

Mahesh 

Bill Sheboy
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.
June 12, 2025

Thanks for that information, and...

With the built-in dashboard pie chart gadget, there is no additional filtering to do that.  Workarounds would be needed, such as:

  • Use separate gadgets which report one of the values at a time for the count (e.g., filter results gadget)
  • Use an additional label custom field, updated with automation rules, which can only contain those two values, and then report on that new field.  This approach is brittle and would potentially consume too much automation execution count.
  • Investigate marketplace addon gadgets which have better filtering / reporting controls
Mahesh June 12, 2025
  • Use separate gadgets which report one of the values at a time for the count (e.g., filter results gadget) --- This is the Problem right Bill, I can't plot a report with individual result out. As with the Query it is bring out rest of the other labels in the filter. 
  • Market gadgets are not allowed for us. 
  • Use an additional label custom field - Thinking to Use Components and separate the values, Need to explore.
Bill Sheboy
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.
June 12, 2025

For the first approach, I meant using something like the Filter Results gadget with a query specifically for one of the Labels.  Then do not display the labels as the count (and perhaps gadget name) would indicate what is needed.

Mahesh June 12, 2025

Can you please share a query with the samples provided above, I am bit confused when you said for one of the Labels.

Bill Sheboy
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.
June 12, 2025

To select just one of the labels do that with the JQL:

project = XXXXX
AND issuetype = Story
AND status = Done
AND labels IN (Customer-Experience)

 

Mahesh June 12, 2025

This returns 3 stories again with other Labels in it, 

Story - 1: Customer-Experience, UAT, Operations, FY26Q1, FY26Q2. 

Story - 2: Customer-Experience, UAT, Operations, FY26Q1.

Story - 5: Customer-Experience, UAT, Operations, FY26Q1, FY26Q2. 

 

That's not my requirement though, I do want to have only Stories with Customer Experience and Operations as labels without other labels.  

Bill Sheboy
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.
June 13, 2025

It appears you have repeatedly changed your scenario.  Which one of these applies:

#1: Return work items which have one-and-only-one label, where that label is either "Customer-Experience" or "Operations".  (In fact, none of the original work item examples you show in your question would match this case.)

#2: Return work items which have at least have the label "Customer-Experience" or "Operations" and only display those specific labels in the results even when the work item contains other labels.

 

I believe the first one (i.e., has only one label) is not possible with built-in JQL features as it can neither count labels nor perform a query join (to remove work items with other labels from the results).  Possible workarounds are:

  • If you only need to perform this check one time, export the work items to a spreadsheet to perform the analysis
  • For more frequent usage...
    • Investigate marketplace addons for JQL for such query types
    • Using a custom field and automation rule, detect this condition and set an "indicator" in the custom field, then use built-in JQL feature to check that custom field.  I described this approach earlier.

If it is the second one (i.e., display only one label), please see my earlier responses describing how to do this.

 

Regardless of which is desired, I recommend pausing and meeting with your Jira Site Admin to describe the need and request coaching on JQL and use of dashboards to answer questions about work items.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events