Unable to count/sum column values
Asked by Ramu:

Hey ..

I have a Confluence Table(it's a plain simple Table updated manually and no macros involved yet) where there are numeric values in say 4 to 5 columns ..

My Ask/Request is:

1. I need to add the SUM of all these values in a Column named Total ..

2. I need to subtract the Leave/Training column values from this Total column and display in the column named Availability

\<i.e., Col Availability = Col Total - (Col Leave \& Col Training)\>.

![Table count.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/329090i7C6AAFCDE33A62B9/image-size/large?v=v2&px=999 "Table count.jpg")

So far, not lucky with Table filter, Transformer macros in achieving this ..

Please help ..


Answers:
author: Stiltsoft support
body: Hi [@Ramu](/t5/user/viewprofilepage/user-id/5453222) ,

The Table Filter and Table Transformer macro treat tables more like mini databases (refer to the column names, calculate totals per row, subtract columns and so on).

For your case the most suitable macro is [Table Spreadsheet](https://docs.stiltsoft.com/tfac/cloud/how-to-use-table-spreadsheet-macro-83100938.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) (if your table is created manually) or [Spreadsheet from Table](https://docs.stiltsoft.com/tfac/cloud/how-to-use-spreadsheet-from-table-macro-152142229.html?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) (if your table is macro generated and comes, for example, from the Page Properties Report, Table Excerpt Include, Jira Issues macros).

There you'll be able to merge cells and use Excel-like cell formulas to calculate totals and subtract them. The report can be also easily formatted as you prefer.

comments: author: Stiltsoft support
body: I've also consulted with the developers regarding the most elegant Table Transformer SQL query for the case:

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

SELECT T1.'Resource',  
FORMATWIKI(SUM(T1.'Role Type' + "\\n")) AS 'Role Type',  
FORMATWIKI(SUM(COALESCE(T1.'Week 1', "_") + "\\n")) AS 'Week 1',  
FORMATWIKI(SUM(COALESCE(T1.'Week 2', "_") + "\\n")) AS 'Week 2',  
FORMATWIKI(SUM(COALESCE(T1.'Week 3', "_") + "\\n")) AS 'Week 3',  
SUM(  
IF(T1.'Role Type' = "Lead", 1, 0) \*  
(COALESCE(T1.'Week 1', 0) + COALESCE(T1.'Week 2', 0) + COALESCE(T1.'Week 3', 0)))  
AS 'Total',  
SUM(  
IF(T1.'Role Type' = "Lead", 1, -1) \*  
(COALESCE(T1.'Week 1', 0) + COALESCE(T1.'Week 2', 0) + COALESCE(T1.'Week 3', 0)))  
AS 'Availability'  
FROM T1 GROUP BY T1.'Resource'

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

As you can see, the SQL query is a working one but maybe it isn't so obvious as using an Excel-like spreadsheet will be.

Hope that the provided options will help your case.


author: Ramu
body: Hey ..

Firstly, glad and a high appreciation for responding in detail .. :) .. it shows the seriousness you maintain on the queries asked .. High respect :)

now, this is not happening for me coz i have the Table in different set up and with my trail and error attempt of implementing the solution is becoming complex .. for example, im not able to enter the values or edit the values etc .... Definitely i agree it is me who is missing something here ..

So, i prefer/request you to please schedule a call support on this ... which i believe is not a too much of ask please ..


author: Stiltsoft support
body: If you need to share any sensitive info, you may refer to [our support portal](https://stiltsoft.atlassian.net/servicedesk/customer/portal/14) that is confidential.

And again the best option is to take the Table Spreadsheet macro where you'll be able to structure your data and use cell formulas as you wish.


author: Ramu
body: Hey ..  

on the same thread from your suggestion of Table Spreadsheet, it works but not helping coz, there are concerns as follows:

1. Unable to expand the Table view size (now there is an option to expand it to the screen full max which is not helping .. there is nothing like drag to an extent or to some pixels size etc ..)

2. I want this page to be visited by resources and add their own numbers every week .. currently, they can but once everyone add the numbers, there is no option to Save ..

Tried checking for it the 'File' menu , pressing ctrl+s etc .. but there is no option .. which beats the whole purpose ..

(there is one auto save but again, not helping coz .. i want a Save option every time when someone visit the page and update their numbers and they have to Save)

My Table spreadsheet in Confluence:

![Table Spreadsheet.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/330089i0C8B19383C9471D4/image-size/large?v=v2&px=999 "Table Spreadsheet.jpg")


author: Stiltsoft support
body: Hi [@Ramu](/t5/user/viewprofilepage/user-id/5453222) ,

You may read about the settings of the macro height here in our documentation: <https://docs.stiltsoft.com/tfac/cloud/how-to-use-table-spreadsheet-macro-83100938.html#HowtouseTableSpreadsheetmacro-SpreadsheetMacroheight>

What concerns the option to save changes, it may be a manual save (you add some changes -\> see the red star near the File menu -\> go to the File menu and click the Save option) or an Autosave.

You may read about the Autosave here: <https://docs.stiltsoft.com/tfac/cloud/how-to-use-table-spreadsheet-macro-83100938.html#HowtouseTableSpreadsheetmacro-SpreadsheetAutosave>


author: Ramu
body: Hey ..

what ever you have mentioned .. yes i have tried BUT, the only main problem/concern is that whatever changes i do it is not getting 'Auto saved' INSPITE of enabling the Auto Save option in the settings. So, a refresh on the page after AUTOSAVE enabled is again loading the initial page and NOT the updated one.

Also, i dont have a SAVE option in my File menu:

![File Settings.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/330112i52F35F55DCC88012/image-size/large?v=v2&px=999 "File Settings.jpg")


author: Stiltsoft support
body: As usual, it happens when you don't have the permissions to edit the page.

Are you sure that you've inserted the macro yourself and not trying to update it from the page view mode on some other page where you are not an editor?

The Save and Save as options should be always present in the File menu if you have all the permissions.


author: Ramu
body: im sure im the one inserted the Macro and it is on the same page .. i have full admin rights on the page i tried coz it is my personal Confluence page ..

not sure why the Save option is not there !!


author: Stiltsoft support
body: Then refer to [our support](https://stiltsoft.atlassian.net/servicedesk/customer/portal/14): attach a page storage (upper right corner -\> menu ... -\> View storage format), insert a new Table Spreadsheet macro and update it while recording a [har-file](https://help.okta.com/oag/en-us/content/topics/access-gateway/troubleshooting-with-har.htm) (also attach it to the ticket) and define what hosting you use (Cloud/Data Center and specify the version of the app if you are on Data Center).


author: Hassen Chtioui_Creativas_
body: Hello Vijay,

This is Hassen from the support team at Creativas, the Smart Tables marketplace vendor.

The powerful functions provided by Smart Tables can help you perform these calculations with Confluence tables. You just need to add the Smart Tables macro and insert a Confluence table.

The following screen recording illustrates how to add the functions on Cloud.

![chrome_oWWUrNtRXx.gif](https://community.atlassian.com/t5/image/serverpage/image-id/329183iCAB36677D8445C5D/image-size/large?v=v2&px=999 "chrome_oWWUrNtRXx.gif")

Smart Tables on Data Center supports these functions as well.

If you have any questions, please feel free to reach out to the [support team](https://creativas.atlassian.net/servicedesk/customer/portals). You can also book a demo for an overview of Smart Tables from [here](https://calendly.com/creativas).

comments: author: Ramu
body: THank you so much Hassen .. unfortunately, i have restrictions where i cant afford any add on on my own ...

may be in Future, definitely will check on this if possible in my Organisation :)

CHeers \& Thanks :)


Tags: confluence-unknown-hosting-type

filter

table

table-filter

table-filter-and-charts

table-filter-charts-spreadsheets

table-spreadsheet

unknown-hosting-type