Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a data view web part (grouped based on different criteria). I added a footer and I would like to generate a total for all the columns.

I was able to calculate a total for basic columns (number columns). However, when I tried to calculate total for a calculated column, I got an incorrect value "NaN":

Click here to view an image of the code and design.

Thanks in advance.

share|improve this question
add comment

2 Answers

I guess all you need is format your xslt formula as a number. Try 'format-number' function or you can use XPath Expression Builder which is available in SharePoint Designer.

share|improve this answer
    
Dedek, I added 'format-number' function: <xsl:value-of select="format-number(sum($nodeset/@ows_Pallets_x0020_On_x0020_Hand), '#,#0;-#,#0')"/> This returned a blank. Since the orginal values were displayed as (e.g.) "float;#17115.00000", I had changed the <td> code to: <xsl:value-of select="format-number(substring-after(@ows_Pallets_x0020_On_x0020_Hand,';#'),'#,‌​##0;-#,##0')" /> Therefore, I also tried the following code for the total: <xsl:value-of select="format-number(substring-after(sum($nodeset/@ows_Pallets_x0020_On_x0020_H‌​and),';#'), '#,#0;-#,#0')"/> Also retruned a blank. –  ssvv May 2 '12 at 13:41
    
@ssw, Plz, update yr main post –  Gennady Vanin Novosibirsk Jun 9 '12 at 17:30
add comment

First, why do you duplicate what is provided by Sharepoint OOTB?

Select DVWP (DataViewWebPart visual web part) on design surface and on ribbon's "ListView Tools" --> "Design" tag --< check "Totals row"

After that you can select a produced total (digit) --> Split (to show both Design and Code in parallel) --> select on ribbon "Design" --> "Customize XSLT" tab (under "Actions" group) --> "Customize Item"

This will highlight you the correct XSL code part for a total which is:

<xsl:value-of select="sum($Rows/@FieldID)" />  

While your code produces incorrect results for non-computed field:

21.724
786
23.204
-------
45.714
share|improve this answer
    
"Totals Row" does not exist for a DataViewWebPart, only for an XsltListViewWebPart. –  Chloraphil Apr 11 at 13:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.