How to sum a calculated column in data view web part?
-
1. května 2012 20:16
I have created a data view web part (grouped based on differnt 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, the total is not correct:
(I know a workaround is entering the formula in the code...but I want to avoid that. I would like a solution that would allow me to get the correct total without coding the formula into the web part.)
Thank you in advance.
Všechny reakce
-
2. května 2012 5:18
Hi
create a new column in your list
Attach a workflow, when an item is changed or added , replace the value in that new column with calculated column value
Next in your dataViewWebPart show that new column.
Romeo Donca, Orange Romania (MCSE, MCTS, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.
-
2. května 2012 13:46
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 in the total cell.
Since the orginal values were displayed as (e.g.) "float;#17670.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')"/>
This also retruned a blank.
- Upravený svaa 2. května 2012 13:47
-
2. května 2012 13:51
Romeo,
Is there a way I can make changes to the code in desinger to get the correct total?
I want to avoid creating multiple columns on the list because majority of my columns are calculated columns.
Thank you
-
2. května 2012 19:54
Hi svaa
you don't need extra code
I reproduced an example for you.
Sum Calcuated Column, posted today May 2. 2012 on my site,
or
you can click here
Romeo Donca, Orange Romania (MCSE, MCTS, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.
- Upravený romeo donca 2. května 2012 19:54
-
4. května 2012 22:38
I did a quick test.
Unfortunately, this did not solve my problem. I will take some time and test it in length.
For the time being I am using formula such as:
sum($nodeset/@Row1)+sum($nodeset/@row2)
Thanks for your help.
- Upravený svaa 4. května 2012 22:39