Sort by ID rather than Name of a custom field in JQL(JIRA)

I have a custom-field "MONTH" with options: jan, feb,..,dec.

Now I want to sort by MONTH so that order will be jan,feb..... Is it possible?

3 answers

1 accepted

0 vote

Jira isn't clever enough to recognise abstracted names like that. I used to cheat by simply padding the names with empty space prefixes, but that's a bit horrid when you do it in JQL. For months, the only fixes I know of are:

  • Prefix month names with 01, 02, 03 etc
  • Write a field that understands that the options are months
  • Wedge in some javascript to do the sort (I avoid javascript as much as possible, and I'm not sure it'll help you here - I suspect you're looking at JQL, where javascript won't help you at all)

I doubt it, since it will sort the content of that field alphabetically.

I am not sure if this answer is covered by Nic's second case, but I have populated a second field with the sort order then using jql to sort by that column. The column does not need to be displayed to sort by it.

Norman,

I am not getting - Can you please elaborate in more details?

It's fourth valid way to do it - you create a new field called something like "sorted month", then use a plugin (script runner) to create a calculated field that populates it with 1 if your main field is Jan, 2 for Feb and so on.

Then your JQL could be something like "month in (Jan, Mar, Apr) order by sorted-month

(My third option was to write a field type plugin that gives you that works like any other select list, but has code that knows how to sort month names correctly. That is more coding than Norman's idea, but the JQL works more intuitively)

Thank you Nic for clarifying my terse description. Your description is exactly what I did and it took no more than 15 minutes to implement.

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
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

727 views 6 13
Read article

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