How to create a summarize table based on columns of a table in confluence?
Asked by Ross:

I have a table like this

![table_a.PNG](/t5/image/serverpage/image-id/145527i8DF6AE753D0E07DC/image-dimensions/285x84?v=v2 "table_a.PNG")

and I want a small summarized pivot table like shown below based on the above table :

![table_b.PNG](/t5/image/serverpage/image-id/145528i7E609AF3C68E34D8/image-dimensions/379x60?v=v2 "table_b.PNG")

How we can achieve this via confluence ? Is there any macro for this ?


Answers:
author: Katerina Kovriga {Stiltsoft}
body: Hi [@Ross](/t5/user/viewprofilepage/user-id/4352829) ,

There are no such macros out-of-the-box, you'll need some additional apps to complete your case.

In [this thread](https://community.atlassian.com/t5/Confluence-questions/How-to-make-pie-chart-for-table-with-categorical-columns-in/qaq-p/1707972) I suggested using our app - [Table Filter and Charts for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluence?hosting=cloud&tab=overview) (it seems that it was also your question judging by the username).

And here is another bunch of screenshots for you: wrap your table into the [Table Transformer](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Transformer+macro) macro.

![Mon 2-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/145532i4F839F0AAE8909AA/image-size/large?v=v2&px=999 "Mon 2-1.png")

![Mon 2-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/145533i5753AAA0AB85C3D4/image-size/large?v=v2&px=999 "Mon 2-2.png")

SELECT "Summary" AS '',  
SUM(IF(T1.'Column A' = "Yes", 1, 0)) AS 'Column A Yes',  
SUM(IF(T1.'Column A' = "No", 1, 0)) AS 'Column A No',  
SUM(IF(T1.'Column B' = "Yes", 1, 0)) AS 'Column B Yes',  
SUM(IF(T1.'Column B' = "No", 1, 0)) AS 'Column B No',  
SUM(IF(T1.'Column C' = "Yes", 1, 0)) AS 'Column C Yes',  
SUM(IF(T1.'Column C' = "No", 1, 0)) AS 'Column C No'  
FROM T1

![Mon 2-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/145534iAC45B7D0C2DCD249/image-size/large?v=v2&px=999 "Mon 2-3.png")

![Mon 2-4.png](https://community.atlassian.com/t5/image/serverpage/image-id/145535iFF6BB7F625591B1B/image-size/large?v=v2&px=999 "Mon 2-4.png")

Hope this helps.

comments: author: Ross
body: Excellent answer [@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746) . Thank you very much.


author: Katerina Kovriga {Stiltsoft}
body: [@Ross](/t5/user/viewprofilepage/user-id/4352829) And here is another more precise SQL query for your case:

SELECT "Yes" AS 'Count',  
SUM(IF(T1.'Column A' = "Yes", 1, 0)) AS 'Column A',  
SUM(IF(T1.'Column B' = "Yes", 1, 0)) AS 'Column B',  
SUM(IF(T1.'Column C' = "Yes", 1, 0)) AS 'Column C'  
FROM T1  
UNION ALL CORRESPONDING  
SELECT "No" AS 'Count',  
SUM(IF(T1.'Column A' = "No", 1, 0)) AS 'Column A',  
SUM(IF(T1.'Column B' = "No", 1, 0)) AS 'Column B',  
SUM(IF(T1.'Column C' = "No", 1, 0)) AS 'Column C'  
FROM T1

![Mon 2-5.png](https://community.atlassian.com/t5/image/serverpage/image-id/145538i8E2877A843493EE1/image-size/large?v=v2&px=999 "Mon 2-5.png")

Now you don't need to transpose tables and your result table is neat and easy to read.


Tags: cloud

confluence-cloud