Show Totals for a Calculated Column

I had a request to show the sum for a calculated column in a list view. In this scenario there is a list of projects with the hours estimated, the actual and the remaining hours for each project. The hours estimated and the hours spent are number columns and the hours remaining is a calculation of the difference. Using the OOB features, we can show totals for the number columns, but not the calculated one (examples below).

 

 

Using SharePoint Designer we can configure the list view to have a calculated column for all three of the columns. Once you open the list view in SPD, you will want to convert the web part to an XSLT Data View.

 

Notice that once it has been converted, the Sums are removed. We will now re-add the different calculations.

 

First, we will need to add a row that will be used to store the columns. In this case, the requirement was that the sums showed at the top of the list. Once we have the added row, we will want to open the Data Source Details and add our desired field.

 

 

Now that the field has been added, we will need to edit the formula so that it is configured to SUM the items. To do this we can right click on the item and select the Edit Formula Option. Note: If you do not insert the item above formatted as a number then you may not see the option to edit the formula.

 

The following image shows the changes that will need to be made in order to SUM the column. You are adding the sum() operator around the field.

 

Once you select OK, you should be able to see that your column is now providing a SUM of the entire column. You can now complete the steps for the remaining columns. Now that the columns are being summed correctly, we can apply any desired formatting. Below is a screen shot of new list view.

 


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s