How to display multiple counts base on data from one table?

Leona May 26, 2022

Hi,

I have one big table that I want to display counts of:

  • Total Number of Rows
  • Count of records with status "OPEN"
  • Calculate Percentage of Done

I was able to populate Table A with three macros (see screenshot). But this solution is heavy and takes a long time to load as I have many other macros on the page. 

Any lightweight solution to look like Table B? Please note, I do not have TRANSWIKI.

Thank you.project.png

1 answer

1 accepted

2 votes
Answer accepted
Srinatha T
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 26, 2022

HI @Leona ,

Welcome to Atlassian community. 

The below thread has some solution for you. It uses table transformer macro. 

Try that. 

Thanks,

Srinath T

Katerina Kovriga _Stiltsoft_
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.
May 27, 2022

Hi @Leona ,

As @Srinatha T has kindly mentioned, the similar case can be achieved with one Jira Issues macro and one Table Transformer macro.

Fri 9-1.png

Fri 10-1.png

SELECT *, 'Open'/'All'*100 AS '% of Completion'
FROM (SELECT SUM(IF(T1.'Status' = "To Do", 1, 0)) AS 'Open',
SUM(IF('Status' IN ("To Do", "In Progress", "Done", "Answered"), 1, 0)) AS 'All'
FROM T*)

To get a vertical table instead of the horizontal one go to the "Settings" tab of the Table Transformer macro and check the "Transpose result table" option.

Hope this helps your case.

Like # people like this
Leona May 31, 2022

Thank you both for the quick response. The solution works beautifully. 

I would use COUNT in the same way as SUM with the IF statement? When then would COUNT be a better solution than SUM? Thanks again.

Like Srinatha T likes this
Katerina Kovriga _Stiltsoft_
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.
May 31, 2022

Hi @Leona ,

What do you mean by a better solution? I don't think that the change of the function will improve your performance or smth.

By the way you can check all the available functions here.

Like Srinatha T likes this
Katerina Kovriga _Stiltsoft_
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.
May 31, 2022

And pay attention to the obtained results:

SELECT SUM(IF(T1.'Status' = "To Do", 1, 0)) AS 'Open' FROM T1

equals to the

SELECT COUNT('Status' = "To Do") AS 'Open' FROM T1 WHERE T1.'Status' = "To Do"

The simple changing of the function's name can lead to incorrect results (your conditions won't be taken into consideration).

You can find more use cases here.

Leona May 31, 2022

Hi Katerina, which of the two would have a better performance from the two examples you provided? COUNT vs SUM? I am learning lots, thanks.

Katerina Kovriga _Stiltsoft_
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.
May 31, 2022

The performance depends more on the number of issues that are returned by your Jira Issues macro and the number of other macros on top.

Here we have one Table Transformer, so only one SQL query will be applied to the source table. And the SUM function just makes the initial SQL query look more neat and easy-to-read.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events