0

I am trying to count the number of roles in a list. There are 3 stages, open, offer and filled. There are 2 departments; infrastructure and business. So i want to display a table with the following headings; DEPARTMENT | OPEN | OFFER | FILLED. I will list each of the departments and then the total count for each value in the list. Below is a sample of the list.

Department     | Status
_________________________
Infrastructure | open
Infrastructure | open
Infrastructure | offer
Infrastructure | filled
Business       | filled
Business       | offer
Business       | open

I want to group the departments by open, offer and filled, and count how many for each and then display this value in the table. The code below shows how i have pulled the infrastructure data from the list.

<xsl:template name="dvt_1">
    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
    <xsl:variable name="dvt_RowCount" select="count($Rows)" />
    <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
    <xsl:call-template name="dvt_1.body">
       <xsl:with-param name="Rows" select="$Rows"/>
    </xsl:call-template>                                                                                                
</xsl:template>

<xsl:template name="dvt_1.body">
    <xsl:param name="Rows" />

    <xsl:variable name="InfraOpen" select="count(/dsQueryResponse/Rows/Row
    [(normalize-space(@Title)='Infrastructure') and (normalize-space(@Status)='OPEN')])"/>

    <xsl:variable name="InfraOffer" select="count(/dsQueryResponse/Rows/Row
    [(normalize-space(@Title)='Infrastructure') and (normalize-space(@Status)='OFFER')])"/>

    <xsl:variable name="InfraFilled" select="count(/dsQueryResponse/Rows/Row
    [(normalize-space(@Title)='Infrastructure') and (normalize-space(@Status)='FILLED')])"/>

   <table width="100%" cellspacing="0" cellpadding="2" 
                       style="border-right: 1 solid #008ce6; 
                       border-bottom: 1 solid #008ce6; 
                       border-left:  1 solid #008ce6; 
                       border-top:  1 solid #008ce6;">
<tr style="font-family: Arial, Helvetica, sans-serif; font-size: small"> 
<th>ORGANISATION</th><th>OPEN</th><th>OFFER</th><th>FILLED</th></tr>

<xsl:call-template name="ChartRow">      
      <xsl:with-param name="RowName">
        Infrastructure
      </xsl:with-param>      
      <xsl:with-param name="ValueOpen">
        <xsl:value-of select="$CISopen"/>
      </xsl:with-param>
      <xsl:with-param name="ValueOffer">
        <xsl:value-of select="$CISoffer"/>
      </xsl:with-param>
      <xsl:with-param name="ValueFilled">
        <xsl:value-of select="$CISfilled"/>
      </xsl:with-param>
</xsl:call-template>
</table>
</xsl:template>

<xsl:template name="ChartRow">
  <xsl:param name="RowName"></xsl:param>
  <xsl:param name="ValueOpen"></xsl:param>
  <xsl:param name="ValueOffer"></xsl:param>
  <xsl:param name="ValueFilled"></xsl:param>

  <tr style="font-family: Arial, Helvetica, sans-serif; font-size: small">
  <td class="ms-formbody" style="vertical-align:middle">
  <xsl:value-of select="$RowName"/>
  </td>
  <td>
    <xsl:value-of select="$ValueOpen"/> 
  </td>
  <td>
    <xsl:value-of select="$ValueOffer"/> 
  </td>
  <td>
    <xsl:value-of select="$ValueFilled"/> 
  </td>
 </tr>
</xsl:template>                 

Below is the desired output

Department     | Open| Offer| Filled
____________________________________
Infrastructure | 2   |  1   |  1
Business       | 1   |  1   |  1

This code works in SP Designer but it is unable to load the webpart in the webpage. I have read up about this and think that i need to use MUENCHIAN grouping, does anyone know how i would approach this?

Aaron C
  • 135
  • 3
  • 12
  • Your question is not clear. Please show an example of the input and the expected output - see [mcve]. – michael.hor257k Jun 30 '16 at 12:23
  • @michael.hor257k tried painting a better picture of current list data and the desired output – Aaron C Jun 30 '16 at 12:33
  • You should post the XML **code** for both, not a "picture". Anyway, this is a *grouping* question. Do a search - it's probably the most often asked XSLT question here. Note that answers are different for XSLT 1.0 or 2.0. – michael.hor257k Jun 30 '16 at 12:34

0 Answers0