How to get the sum of tickets in a filter per priority Smart Values

Julia September 26, 2022

I'm trying to figure out which smart values I can use to get the # of tickets in a certain filter that have priority low, medium, high. 

In the atlassian documentation it says this is possible with the ".size" but I can't get that to work. 

These smart value keep returning 0. Any ideas? Screen Shot 2022-09-26 at 11.27.51 AM.png

3 answers

1 accepted

5 votes
Answer accepted
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.
September 26, 2022

Hi @Julia 

First, a disclaimer: I am using Jira Cloud and not Server / Data Center, so I cannot verify this suggestion.

Your Jira version has bulk operations on {{issues}} for a branch or scheduled trigger, and I believe this will work, where you may change the priority names for your own:

{{issues.priority.name.match("(Highest)").split(",").size|0}}

What this is doing is...

  • grab the list of the priority names from all of your issues
  • use a regular expression to match() on the name...producing 0-to-many values in a comma-separated values list
  • split that into a smart value list
  • count the items with size
  • and add a default value of zero in case nothing was found

Kind regards,
Bill

Julia September 27, 2022

This worked thank you so much! 

Like # people like this
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.
September 27, 2022

I am glad to learn that worked for you!  The same technique works for Jira Cloud with Lookup Issues, and it is quite handy for reporting emails send by automation.

Like John Funk likes this
0 votes
Erez Ben-Or
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 12, 2023

Hi @Bill Sheboy 

Thank you for being so helpful.

I was wondering how I should use this command
{{issues.priority.name.match("(Highest)").split(",").size|0}}

In case I would like to count two values at the same time.
For example, both "Critical" and "High"

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.
July 12, 2023

Hi @Erez Ben-Or -- Welcome to the Atlassian Community!

When reviewing an older question like this, please create a new question and then provide a link back to the older one for context.  Otherwise only the people following this thread will see it.  Thanks!

Back to your question...

First, are you using Jira Cloud or Jira Server/Data Center version?  Only the automation rules for Server/Data Center have access to the {{issues}} (note the plural) smart value.  Jira Cloud instead uses the Lookup Issues action and the {{lookupIssues}} smart value.

Let's assume you are using Server/Data Center...

To get each count, you would need a separate expression for each one, Critical and High.  If you wanted their total, you may use a math expression to sum them

{{#=}}{{issues.priority.name.match("(Critical)").split(",").size|0}} + {{issues.priority.name.match("(High)").split(",").size|0}}{{/}}

Kind regards,
Bill

Like # people like this
Erez Ben-Or
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 12, 2023

Thank you for clarifying the reviewing issue and thank you for the answer.


Like Bill Sheboy likes this
0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 26, 2022

Hello @Julia 

Can you provide the full content of your automation rule, and a link to the document you are referencing when you get information about ".size"? That will help us provide answers relevant to your context.

The "size" property is relevant to have a list of items. There may be other ways to handle this but I would try using the Lookup Issue action to get a list of issues in a given priority and then use {{lookupIssues.size}} to get the number of issues in that list. If you are trying to get the counts for multiple lists into another single action (like Send Mail) you would need to assign the {{lookupIssues.size}} value for each Lookup Issues action to a separate variable, I think, as each LookupIssues action would overwrite the results of the previous action.

Julia September 26, 2022

https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html 

 

The entire context is this:

  • Scheduled Trigger to run Daily with JQL being a certain filter 
  • Send an email with the sum of the # of tickets within that filter by each priority
    • i.e. how many are low, medium, high 

 

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 26, 2022

Thank you for that additional information.

In this scenario you can't use "size" to get a count of a subset of the issues returned by your JQL. You can get a count of all the issues returned by the JQL or a count of the Comments associated to an issue in the list, but not a count of a subset of issues in the results.

You could create multiple scheduled rules, each with a JQL that retrieves the issues for a specific priority, and use {{issues.size}} in a Send Mail action to get the count for issues for that one priority.

Alternately you can do as I suggested before and create multiple Lookup Issues actions, each with a JQL that gets issues for one priority, and collect the size of each result set in a unique variable. Then include all those variables in your Send Mail action. In that scenario you would not have the JQL as part of the Trigger.

Julia September 26, 2022

Is your solution possible on Jira Server? I think that may be only available for cloud?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 26, 2022

Oh, I apologize. I did not notice that your post was tagged for Jira Server. The Lookup Issues action is not available there, but there is a change request for it.

https://jira.atlassian.com/browse/JIRAAUTOSERVER-53

I think then in your scenario you would need to run the JQL per priority in separate rules.

Suggest an answer

Log in or Sign up to answer