Max function in Jira smart values

Raju Mandapaka February 15, 2021

Hi Team,

How to find out min or max value in a smart value generated by jira automation.

In an automation i started figuring out some numbers from user stories under epics, now i want to list out which is max & min in that list.

here is the sample pic of audit log

image.png

I need to find which is maximum value in (25, 11, 15,-2)

 

Thanks in Advance.

 

Raju

2 answers

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.
February 17, 2021

Hi @Raju Mandapaka 

If the LookupIssues action supported all fields, which it does not yet do, this would be easy. Here is a suggestion to add that capability: https://jira.atlassian.com/browse/JRACLOUD-75018

Until then you may try a couple of work-arounds using automation rules.

  • Simple solution: Add custom fields to the parent epic (maxMyNumber and minMyNumber), and every time a child story is updated such that it has a new max/min, trigger a rule to update the parent's custom fields.  They should then be up to date when you need them.
  • Very complex solution: Send a web request from the rule to call the REST API for a JQL search of issues, ordering the results by your number field.  Parse the resulting JSON to get your custom field values, putting them into a created variable as a CSV list.  Use the text and list functions to get the min and max from the list.  (Honestly, I only did this one to see if it was possible.  I do not recommend it.)

Best regards,

Bill

Raju Mandapaka February 18, 2021

Hi @Bill Sheboy 

Let me clearly explain my concern/problem.

I want to get the latest sprint name that has longest timeline or close at last.

Lets say, EPIC-1 stories are distributed in 3 sprints with different end date.

Epic 1:

-sprint 1 - Timeline: 10-28-2019 to 11-15-2019

--- Story1

--- Story2

-Sprint 2 - TImeline:  11-04-2019 to 11-12-2019

--- Story1

--- Story2

-Sprint 3 - TImeline:  11-04-2019 to 11-29-2019

--- Story1

--- Story2

The script should return "Sprint 3" name. I able to find the sprint name and date value for each sprint but i not sure how to compare date for each sprint and get the latest sprint date.

Thanks in advance

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.
February 18, 2021

Hi @Raju Mandapaka 

Thanks for clarifying your question. 

For looking at historical data (past sprints), I have always done comparisons like this by exporting to a spreadsheet and parsing the results.  Jira adds new sprints to an issue when items are carried over, and I do not believe the built-in automation rule functions can easily determine the maximum/latest sprint in the field.

For future sprints which have not started yet, I suggest using the custom field method, such as maxSprintStartDate in the epic, and use a rule triggered on Sprint Started to walk the issues and update the parent epic.  Jira date (and date/time) values are just numbers and so you can compare to find the latest one for updates... Or, always assume your sprints are non-overlapping and the "last update" is always used.

Like Raju Mandapaka likes this
Raju Mandapaka February 18, 2021

Hi @Bill Sheboy 

 

I am looking for a automation rule

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.
February 18, 2021

I understand your request, and the only way I see to do this currently is the method I noted with the web request call to the REST API, and using extra custom fields.

For one individual issue the maximum Sprint Date value is {{issue.sprint.endDate.max}} but getting at that value spanning a list of issues is the challenge.  If you use one rule to save the max in a custom field for each issue and then a second rule with the web request method, you can get to one maximum value spanning the set.

 

It would be easier to just update the parent epic when a sprint starts with a date later than some field in the epic in a single rule.

Like Raju Mandapaka likes this
Raju Mandapaka February 18, 2021

Thanks @Bill Sheboy for the information, can you please elaborate more about the second rule web request method.

I am not having any idea about 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.
February 18, 2021

Please see my earlier post in this thread mentioning Very complex solution for details:

https://community.atlassian.com/t5/Jira-questions/Re-Max-function-in-Jira-smart-values/qaq-p/1616008/comment-id/467134#M467134

0 votes
Gareth Cantrell
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.
February 15, 2021

Hi @Raju Mandapaka 

If the numbers are in a list, you can use the list.min and list.max functions as described here: https://support.atlassian.com/jira-software-cloud/docs/smart-values-lists/

For example, if you use the Lookup issues action, you could do something like {{lookupIssues.Story Points.min}} and {{lookupIssues.Story Points.max}}.

Raju Mandapaka February 16, 2021

Hi @Gareth Cantrell 

First thing is, those values are not in a list (they are individual values generated from stories under an epic) and the functions list.max or list.min are not working.

In this view i am having 2 questions.

Question 1: How to create a list of those values??

Question 2: Is there any custom field which stores multiple numerical values.

 

Thanks in advance,

Raju

Gareth Cantrell
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.
February 17, 2021

@Raju Mandapaka how are you defining your rule? If you can share a screenshot of what your rule looks like, rather than the audit log, we can make a suggestion that may help.

Raju Mandapaka February 18, 2021

@Gareth Cantrell ,

Let me clearly explain my concern/problem.

I want to get the latest sprint name that has longest timeline or close at last.

Lets say, EPIC-1 stories are distributed in 3 sprints with different end date.

Epic 1:

-sprint 1 - Timeline: 10-28-2019 to 11-15-2019

--- Story1

--- Story2

-Sprint 2 - TImeline:  11-04-2019 to 11-12-2019

--- Story1

--- Story2

-Sprint 3 - TImeline:  11-04-2019 to 11-29-2019

--- Story1

--- Story2

The script should return "Sprint 3" name. I able to find the sprint name and date value for each sprint but i not sure how to compare date for each sprint and get the latest sprint date.

Thanks in advance

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events