[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Sum in a Grouping
Subject: [xsl] Sum in a Grouping From: Linda <binky_35@xxxxxxxx> Date: Fri, 24 Aug 2001 09:43:57 -0400 (EDT) |
I am trying to sum a value in a group, in a cell, in a table. I am able to count the items and display only the last one but I can't figure out how to sum the numbers up. XML snip: <RECORD> <START_TIME>2001-06-19 09:00:07.0</START_TIME> <SHIPMENT_GID>WELKE.260</SHIPMENT_GID> <ORDER_RELEASE_GID>WELKE.ORDER BASE ID-001</ORDER_RELEASE_GID> <INVOLVED_PARTY_LOCATION_GID>CUSTOMER1.CUSTOMER1_SHIPFROM1</INVOLVED_PARTY_LOCATION_GID> <NET_AMOUNT_DUE>359.72</NET_AMOUNT_DUE> <CURRENCY_GID>CAD</CURRENCY_GID> <TOTAL_ACTUAL_COST>92.64</TOTAL_ACTUAL_COST> <T_ACTUAL_COST_CURRENCY_GID>CAD</T_ACTUAL_COST_CURRENCY_GID> <TOTAL_ALLOC_COST>23.03</TOTAL_ALLOC_COST> <INVOICE_GID>WELKE.CB-20010710-0021</INVOICE_GID> <ORDER_BASE_GID>WELKE.ORDER BASE ID</ORDER_BASE_GID> </RECORD> The count works like this: <xsl:key name="records-by-party" match="RECORD" use="INVOLVED_PARTY_LOCATION_GID"/> <xsl:for-each select="RECORD[count(. | key('records-by-party', INVOLVED_PARTY_LOCATION_GID)[1]) = 1]"> <hr/> <xsl:sort select="INVOLVED_PARTY_LOCATION_GID" /><br /> <br /> <xsl:for-each select="key('records-by-party', INVOLVED_PARTY_LOCATION_GID)"> <xsl:sort select="START_TIME" /> <xsl:choose> <xsl:when test='position()=last()'> <xsl:text>= </xsl:text><xsl:value-of select="last()"/><br/> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text><br/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:for-each> Which displays nicely as: =1 =8 =3 But I can't get the sum of the values in 'NET_AMOUNT_DUE', I keep getting each line in the group displaying over again - or in this example case - just the last one. <xsl:for-each select="RECORD[count(. | key('records-by-party', INVOLVED_PARTY_LOCATION_GID)[1]) = 1]"> <hr/> <xsl:sort select="INVOLVED_PARTY_LOCATION_GID" /><br /> <br /> <xsl:for-each select="key('records-by-party', INVOLVED_PARTY_LOCATION_GID)"> <xsl:sort select="START_TIME" /> <xsl:choose> <xsl:when test='position()=last()'> <xsl:text>= </xsl:text><xsl:value-of select="NET_AMOUNT_DUE"/><br/> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text><br/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:for-each> Please help, if you know! I have exhausted all books and web sites! Thanks in advance. Linda _______________________________________________________ Do You Yahoo!? Get your free @... address at http://mail.yahoo.ca XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] selecting parents of node-set, Wilcox, Paul | Thread | Re: [xsl] Sum in a Grouping, Jeni Tennison |
Re: [xsl] The Match Game vs The Nam, Sullivan, Dan | Date | Re: [xsl] dynamic xsl transformatio, Mark Galbreath |
Month |
Keywords