Breadcrumbs

Count changes to current status

📚

This template displays the number of times that the current work item was changed from any status to the current status.

Configuration

To use the Count changes to current status template, simply select it from the template grid. Filter by Status to find it faster.

Parameters

This template does not require any additional parameter configuration.

Expert mode

If you switch to Expert mode you can see the formula field in the Expression Parser. You can now tweak the expression to create a custom formula field based on this template.

Expression

Jira expression:

issue.changelogs.filter(changelog => changelog.items.some(item => item.fieldId == 'status' && item.toString == issue?.status?.name)).length

If it is only necessary to display the number of times that the work item has been in a specific status, replace issue?.status?.name with the name of the status between brackets, e.g. 'Rejected'.

Display as

Number

Formatting style

Default (unformatted)

Details

1. What does the expression do?

This expression counts how many times the current work item has been changed from any status to its current status. In other words, it tells you how many times the status of the work item was set to its present value.


2. Step-by-step breakdown

Let’s break it down:

  • issue.changelogs: This refers to the complete history of changes (changelogs) for the work item.

  • .filter(...): This narrows down the changelogs to only those that meet a certain condition.

  • changelog => ...: For each changelog entry, we check if it contains a change to the status field.

  • changelog.items.some(...): Each changelog can have multiple items (fields that were changed at that time). This checks if any of those items:

    • item.fieldId == 'status': The field that was changed is the status.

    • item.toString == issue?.status?.name: The new value of the status (after the change) matches the current status of the work item.

  • The filter keeps only those changelogs where the status was changed to the current status.

  • .length: Counts how many changelogs matched the above condition.


3. Examples

  • If a work item started as "To Do", was moved to "In Progress", then back to "To Do", and is currently "To Do", the expression would count how many times the status was set to "To Do" (including the current one).

  • If the current status is "Done" and the work item was moved to "Done" three times in its history, the result will be 3.


4. Real-life use cases

  • Tracking Reopened Work Items: If you want to know how many times a work item was moved back to "In Progress" after being completed, this expression helps you track such cycles.

  • Quality Control: For statuses like "Rejected" or "Needs Review", you can see how often a work item required re-evaluation.

  • Process Optimization: By counting how often work items return to certain statuses, teams can identify bottlenecks or recurring issues in their workflow.