0

Using: SharePoint 2010, Designer 2010

I have a SharePoint list rendered in a view. It is grouped by the values of one column, it is called "Cost-Center". I would like to sum the values of the "Budget" column per "Cost-Center". So if I have three "Employees" in "Cost-Center: 1" who each have a budget of 2 dollars, I would like to learn how to write XSLT or XPATH that can say "Sum the budget column whenever Cost-Center = 1" and so on for other "Cost-Centers".

<xsl:value-of select="sum($nodeset/@Budgeted_x0020_FTE) *WHERE COST-CENTER = VALUE*"/>

The value has to equal the value of the "Cost-Center" for the current group, if that makes sense.

The idea here is to use list view grouping to create accordion style dashboard. Any direction is appreciated. Thanks!

EDIT 1 : Added Code Example

  • 1
    I don't have a sample in front of me, but you typically put that in the template that generates the group headers and just do a sum of the $nodeset/@field I believe. – Eric Alexander Oct 23 '13 at 20:11
  • This is an interesting suggestion. I can tell that your suggestion is on the right path. Thanks for the direction - any other suggestions or ideas would be appreciated. I am slowly gaining proficiency in XSLT after coming from other languages. Cheers! – SynchronizeYourDogma Oct 24 '13 at 13:53
0

Take a look at the XSLT in this post http://paylord.wordpress.com/2012/03/18/sharepoint-list-risk-matrix-using-xslt/ - it uses the same concept so should get you going in the right direction.

0

I have found a solution that works. If this solution is an optimal way to generate results is the topic of further inquiry.

I had a template which defined the grouping of the dataform webpart to which I added the param call "jobset". This "jobset" param was referencing the parent header of the current nested group For example:

Group Header 0 ($groupheader0)

Group Header 1 ($groupheader1)

<xsl:call-template name="dvt_1.groupheader1">
    <xsl:with-param name="fieldtitle">Job Title</xsl:with-param>
    <xsl:with-param name="fieldname">Job_x0020_Title</xsl:with-param>
    <xsl:with-param name="fieldvalue" select="$groupheader1" />
    <xsl:with-param name="fieldtype" select="'Choice'" />
    <xsl:with-param name="nodeset" select="msxsl:node-set($dvt_Rows)/root//Row[((@Job_x0020_Title)=$groupheader1 or ((not(@Job_x0020_Title) or @Job_x0020_Title='') and $groupheader1=' '))]" />
    <xsl:with-param name="jobset" select="$groupheader0" />
</xsl:call-template>

With "jobset" added I created the following statement:

<xsl:value-of select="format-number(sum(/dsQueryResponse/Rows/Row[@Job_x0020_Title = $fieldvalue and @Test_x0020_Cost_x0020_Center = $jobset]/@Budgeted_x0020_FTE),'0.0')"/>

This provided me with the correct information.

It says to take the sum of each @Budget FTE column in each row where the Job Title is equal to the current child group header and the @Test Cost Center is equal to the parent group header.

-Group Header 0 - "Emergency Medical Department"

--Group Header 1 - "Registered Nurses"

---RN - A - Budget FTE: 1
---RN - B - Budget FTE: 1
---RN - C - Budget FTE: 1

-Group Header 1 - "Doctors"

--Doctor - A - Budget FTE: 1

-Group Header 0 - "Burn Unit"

--Group Header 1 - "Registered Nurses"

---RN - A - Budget FTE:1
---RN - B - Budget FTE:1

The statement sums all the Budgeted FTE for the RNs in the ER Department and displays that on the header
Then, the statement sums all the Budgeted FTE for the Doctors in the ER and displays that on the header

And so on....

Thank you for all your help. I appreciate any critique as I am sure this may not be the best way to do this. Thanks!

-S

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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