in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Marian Lishman's Blog

From STS to WSS and beyond :-)

Putting totals in for a field that is a calculated one

I have often thought it a bit strange that you cannot total a calculated field, particularly when it is a number. I managed to acheive this a while ago but had forgotten how I did it so now I am going to put in down in writing so that I don't forget!

You need to change the view to a datasheet one in Frontpage. Then go to the code and find the ??? that ends the display of all the data. Between that and the ??? enter another row and the required number of table cells.

Then add the xsl code that will sum that field - in my case this makes the xml like this:


           
               
                Total Cost: <?xml:namespace prefix = xsl /><xsl:value-of select="sum(<A href='$Rows/@TotalCost)"></xsl:value-of>$Rows/@TotalCost)"/>>
           
       
       

For some reason I don't seem to have the option of formatting this as a number in FrontPage so I guess I will need to do that in the XSL as well.

Comments

 

Wolfgeek said:

Here is a work-around to do totals (and subtotals when using Group By options in a standard list view with calculated fields.

Let's say we have a field called CALCULATED HOURS that is calculated as Round((([END TIME] - [START TIME])*24),1) (this gives the decimal notation of the total time rounded to the closest 10th).

Create a regular number field (not calculated) called HOURS.

Using Sharepoint Designer, create a workflow for your list that runs when list items are created and when list items are changed.

The workflow will have a single step.  Leave the condition field blank.  

In the action section, choose "Set field in the current item".

Click on the word "field" and choose HOURS.

Click on the word "value" and then click on "fx" to do a lookup.

Choose "current item" for the source.

Choose "CALCULATED HOURS" for the field.

Click Finish

Now whenever someone creates or modifies a  list item the non-calculated field will automatically be updated with the data from the calculated field.

Now you can display the non-calculated field in your standard list views, total by it, etc.

Hope that saves people the time it took me to figure it out! ;-)

March 13, 2008 9:03 AM
 

B schneider said:

Great solution!

April 21, 2008 8:29 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

About lishmanm

STS, WSS v2 - 4 years WSS v3 - beginner :-)

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts