Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Iterate over a list of substrings and find the lowest

Chris Smith February 16, 2023

Hi there!

    I have a field in my JIRA issues which is basically a set of comma separated numbers (with max 999). Im looking to find a way to iterate through them using the various automation functions and select the lowest of them. I cant seem to grasp how to use the # operator and the list functions to do this.  So effectively I want to do the equivalent of this pseudocode

int lowest = 1000

for (int i =0 i< list.length(); i++) {

    if (list.get(i) < lowest {

           lowest=list.get(i)

    }

}

I'd really appreciate any tips on how to attack this problem

Thanks in advance!

Chris

 

3 answers

2 accepted

1 vote
Answer accepted
Riley Venable
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2023

You can use the MIN() function in JQL to find the lowest number in a list. For example, if you have a field called "numbers" with a list of comma-separated numbers, you can use the following query to find the lowest number: MIN(numbers) Keep in mind that Jira rounds decimals to the nearest 1000th place, and people can enter large numbers using scientific notation.

1 vote
Answer accepted
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, 2023

Hi @Chris Smith 

This is can be done quite simply with some of the smart value functions available in Jira automation.

In your case, the following smart functions will achieve your outcome:

{{description.split(",").min}}

 I used the description field, so just replace that with your actual field.

Chris Smith February 17, 2023

Wow. That was easy - thanks for answering Gareth. I feel a bit stupid now :-) Do see a way to extend this to reordering the whole list?

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, 2023

Unfortunately, there is currently no option to sort lists. 

I believe there are some feature requests for this which you could vote for.

You can search through these projects on JAC, depending on which platform you're on: https://jira.atlassian.com/projects?selectedCategory=all&selectedProjectType=all&contains=automation&sortColumn=name&sortOrder=ascending&s=view_projects

0 votes
Susan Walker March 31, 2024

in excel i have a column that has 2 values separated by a comma. How do i return the max value in that field

 

 

Susan Walker March 31, 2024

in powerbi i have a column that has text in in and I need to remove it. how do i do that

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events