xsl-list
[Top] [All Lists]

RE: Grouping and Subtotals

2003-04-01 12:27:28
Thank you for the response.  It was a complete oversite to use
$currentGroup/./ProjectedUnits.  It works perfectly fine using the
syntax $currentGroup/ProjectedUnits.

This may veer off onto another subject and if it belongs in another
thread, tell me, but now that I have the subtotals displayed correctly,
it brings up a problem with sorting. The data is still sorting in
relation to the complete document so I don't receive an accurate sort on
the subtotal values.  Is there a way to sort on the aggregate?

Thank you.
Dave

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
David
Petersen
Sent: Tuesday, April 01, 2003 11:40 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Grouping and Subtotals 


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





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>