Jira labels are a great way to quickly categorize issues. Everyone can add labels and they can do so anytime. Labels can also be easily searched and filtered making them a great fit for dashboard widgets and reports. If you are new to Jira's labels, also check out our Ultimate Guide to Jira Labels.
But how to view all the labels used in Jira? And how to find how many times a label is used in Jira? No, you do not need to compile it by hand! You can do it with one easy Jira Expression, of course! This article will show you how to use a combination of JQL and Jira Expressions to find all labels used in Jira and how often they have been used.
You do not need any extra apps to follow along – everything can be done via the Jira Expression REST API. However, the easiest way to work with Jira Expressions is to use our free app, Expression Tester. You can install the Expression Tester from the Atlassian Marketplace.
First, we need to find all the issues that have one or more labels assigned to them. We can do that with a super-short JQL query: labels is not EMPTY
This returns a list of issues that we can work with in a Jira Expression. Of course, there is a lot of info in that list and we just want the labels. So let’s use map() to only keep the label information and then flatten() to turn a list of lists into a single list:
Pretty good, but not quite what we want. That list contains a lot of duplicates and it would be cool if we had some idea how may times a label has been used. Again, Jira Expressions to the rescue! As we have explained here, the reduce() function can help us by counting how many times it sees a label. Our final Jira Expression looks like this:
Putting that expression to work, we finally get a list of all labels in our Jira instance along with how many times they have been used:
And there you go: A list of all labels in your Jira instance, available with the click of a button. And easily downloadable as a JSON object. Depending on how intensively your team uses labels, you will probably see a lot more labels and a lot higher numbers.
This has been a really quick and easy way to get a rough overview of the labels in your Jira instance, but of course, there’s always a catch. If you are an expert with Jira and JQL you can probably already guess: There is an in-built limit to how many issues are returned in a single query. So, for large instances, our quick and easy way will not cut it. If you happen to hit that limit, there are two things you can do:
Hopefully, this short article was helpful for you and showed how versatile Jira Expressions are. Do you have any cool use-case for Jira Expressions? Let us know!