|
Subject: RE: [xsl] Grouping and Subtotals From: "David Petersen" <david@xxxxxxxxxxxxxx> Date: Tue, 1 Apr 2003 11:40:11 -0600 |
I may have stumbled upon the solution after posting this message:
After the <xsl:for-each select> line, I created a $currentGroup
variable. I then used it during the sum operation. So far in my
testing, it appears to work. Can anyone see anything wrong with this?
------------------------------------------------------------------------
-----------------
<xsl:key name="listofbrochures" match="RECORD" use="BrochureName" />
<xsl:template match="DATA">
<table>
<xsl:for-each select="RECORD[count(. |
key('listofbrochures',BrochureName)[1]) = 1]">
<xsl:variable name="currentGroup" select="key('listofbrochures',
BrochureName)" />
<tr>
<td nowrap="true" class="dataValue">
<xsl:value-of
select="BrochureName"/>
</td>
<td align="center" class="dataValue">
<xsl:value-of
select="format-number(BrochureID,'#,##0')"/>
</td>
<td align="right" class="dataValue">
<xsl:value-of
select="format-number(sum($currentGroup/./ProjectedUnits),'#,##0')"/>
</td>
<td align="right" class="dataValue">
<xsl:value-of
select="format-number(sum($currentGroup/./ProjectedForActual),'#,##0')"/
>
</td>
<td align="right" class="dataValue">
<xsl:value-of
select="format-number(sum($currentGroup/./ActualUnits),'#,##0')"/>
</td>
<td align="right" class="dataValue">
<xsl:value-of
select="format-number(sum($currentGroup/./RemainingProjected),'#,##0')"/
>
</td>
</tr>
</xsl:for-each>
<tr>
<td colspan="2" class="dataValue"
align="right"><strong>Totals:</strong></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//ProjectedUnits),'#,##0')"/></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//ProjectedForActual),'#,##0')"/></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//ActualUnits),'#,##0')"/></td>
<td class="dataValue" align="right"><xsl:value-of
select="format-number(sum(//RemainingProjected),'#,##0')"/></td>
</tr>
</table>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Grouping and Subtotals, David Petersen | Thread | Re: [xsl] Grouping and Subtotals, David Carlisle |
| [no subject], David Alcantara | Date | Re: [xsl] name() of root element, David Carlisle |
| Month |