views:

466

answers:

1

I have a column, B, that is calculated based on another column, A. At the top of the list, I'd like to display the sum of B. When I look in the Totals section in the Create/Modify a Column screen, I only see column A (actually, I only see all the non-calculated columns), so I can't choose to sum column B.

Is there a way to display a total for column B?

+1  A: 

I found something that feels like a hack, but it works:

  1. Using a web browser, edit your desired list to use “Totals” on at least one column in your list.
  2. Open your desired SharePoint site in SharePoint Designer.
  3. In the Folder List view, find your desired list in the Lists folder.
  4. Open AllItems.aspx (or whatever view you want to edit).
  5. In the Web Parts inspector, Web Parts tab, click the "Username Gallery" and the Web Part List below that will display a list that includes a Content Editor Web Part (CEWP).
  6. Drag the CEWP into the AllItems.aspx (or whatever) view you have open.
  7. Save the aspx file.
  8. Go to this JQuery web page and copy whichever script you're interested in to the clipboard.
  9. Go to your SharePoint list using a web browser.
  10. You'll see a line of text there now, where you put the CEWP: "To add content, open the tool pane and then click Rich Text Editor." Click on the "open the tool pane" link.
  11. Click the Source Editor button on the right.
  12. Paste the script in the clipboard into the Source Editor window.
  13. Change the "var col = 4; //which column to sum" line so that the column number is the one you want to sum.
  14. Click the Save button and then the OK button in the bottom right.

Voila!

Unfortunately, this solution is very brittle. If you make any changes to the page in SharePoint Designer and save the aspx file again, the script code that you put in the CEWP is lost and you have to re-paste it back in again. To make it less brittle, you can just reference the code in a separate file. To do this, remove the code from the CEWP's Source Editor, save the code as a ".js" file in another SharePoint list (e.g., create a new one called "Resources"), copy the URL of that file, and paste the URL into the text box under "To link to a text file, type a URL".

Rachel