xsl-list
[Top] [All Lists]

sum based on grouping by date and node

2004-12-05 17:50:49
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))&gt;=
concat(substring($global,7),substring($global,1,2),substring($global,4,2))]
   
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))&lt;
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))&gt;=
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))&lt;
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))&gt;=
concat(substring($global,7),substring($global,1,2),substring($global,4,2))]

   
[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))&lt;
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))&gt;=
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))&lt;
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>






--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • sum based on grouping by date and node, dmitrik <=