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.

3 Answers 3


I encountered this when I was enhancing our databases. Sharepoint never convert a blank item into "zero" that's why when you total the column, it displays "Nan". You have to manually/automatically put zero on blanks. :)


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.

  • 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_Hand),';#'), '#,#0;-#,#0')"/> Also retruned a blank.
    – ssvv
    Commented May 2, 2012 at 13:41
  • @ssw, Plz, update yr main post Commented Jun 9, 2012 at 17:30

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:

  • "Totals Row" does not exist for a DataViewWebPart, only for an XsltListViewWebPart.
    – Chloraphil
    Commented Apr 11, 2014 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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