[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] sum based on grouping by date and node
Subject: [xsl] sum based on grouping by date and node From: dmitrik@xxxxxxxxxxxxxx Date: Sun, 5 Dec 2004 19:50:49 -0500 (GMT-05:00) |
The follwing xml and xsl sum the StepCharge_TTBlack value by TradeID and Customer. How is it possible to display the sums while using the same date groupings but also based on grouping by the Customer node instead of TradeID? Thanks, Dmitri <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes" /> <xsl:variable name="global"> <xsl:value-of select="Portfilio/AsOf"/> </xsl:variable> <xsl:template match="/"> <html> <head> <title>Portfilio</title> </head> <body> <table border="0" width="100%" cellpadding="10"> <tr><b>Credit Risk</b></tr> <tr><b>Customer Buckets Report</b></tr> <tr><b>As Of: </b><xsl:value-of select="$global" /></tr> </table> <xsl:apply-templates /> </body> </html> </xsl:template> <xsl:template match="Portfilio"> <html> <style> td { width: 120px; font-family:verdana; font-size:10px; } .r0 {background-color: #f0f0f0} .r1 {background-color: white} </style> <body> <table border=".5"> <tr> <!--<td ><b>Trade Id</b></td>--> <td align="center"><b>Customer</b></td> <td align="center"><b>0</b></td> <td align="center"><b>3</b></td> <td align="center"><b>TradeId Totals</b></td> </tr> <xsl:for-each select="Trade"> <tr class="r{position() mod 2}"> <td> <xsl:value-of select="TradeId"/><xsl:text/></td> <!--<td align="right"> <xsl:value-of select="Portfilio/Trade/Customer"/> </td>--> <td align="right"> <xsl:value-of select="format-number(sum(Portfilio/Trade/Step [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))>= concat(substring($global,7),substring($global,1,2),substring($global,4,2))] [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))< concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))] /StepCharge_TTBlack), '###,###,##0')"/> </td> <td align="right"> <xsl:value-of select="format-number(sum(Portfilio/Trade/Step [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))>= concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))] [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))< concat(substring($global,7)+6,substring($global,1,2),substring($global,4,2))] /StepCharge_TTBlack), '###,###,##0')"/> </td> </tr> </xsl:for-each> <tr> <td><b>Yearly Totals</b> </td> <!--<td> </td>--> <td align="right"><b> <xsl:text/> <xsl:value-of select="format-number(sum(Trade/Step [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))>= concat(substring($global,7),substring($global,1,2),substring($global,4,2))] [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))< concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))] /StepCharge_TTBlack), '###,###,##0')"/> </b></td> <td align="right"><b> <xsl:value-of select="format-number(sum(Trade/Step [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))>= concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))] [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))< concat(substring($global,7)+6,substring($global,1,2),substring($global,4,2))] /StepCharge_TTBlack), '###,###,##0')"/> </b></td> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet> <Portfilio> <AsOf>11/01/2004</AsOf> <Trade> <TradeId>ED.TEST</TradeId> <Customer>ABC</Customer> <Step> <MinFlowDate>11/30/2004</MinFlowDate> <StepCharge_TTBlack></StepCharge_TTBlack> </Step> <Step> <MinFlowDate>11/30/2005</MinFlowDate> <StepCharge_TTBlack>6</StepCharge_TTBlack> </Step> </Trade> <Trade> <TradeId>ED.TESTFX1</TradeId> <Customer>AAA</Customer> <Step> <MinFlowDate>12/11/2004</MinFlowDate> <StepCharge_TTBlack>3</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>12/11/2004</MinFlowDate> <StepCharge_TTBlack>61</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>12/11/2005</MinFlowDate> <StepCharge_TTBlack>11</StepCharge_TTBlack> </Step> </Trade> <Trade> <TradeId>ED.TESTFX1</TradeId> <Customer>AAA</Customer> <Step> <MinFlowDate>12/11/2004</MinFlowDate> <StepCharge_TTBlack>3</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>12/11/2004</MinFlowDate> <StepCharge_TTBlack>61</StepCharge_TTBlack> </Step> <Step> <MinFlowDate>12/11/2005</MinFlowDate> <StepCharge_TTBlack>11</StepCharge_TTBlack> </Step> </Trade> </Portfilio>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Extracting the grouping f, Kevin Jones | Thread | [xsl] Dictionary Headers, tsterlin |
[xsl] Extracting the grouping from , Peter Wyngaard | Date | RE: [xsl] Dumping a variable, Marian Olteanu |
Month |