[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Trying to display Summed Average of Grouped Data

Subject: Re: Trying to display Summed Average of Grouped Data
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 30 Aug 2004 16:55:44 +0100
xsl average
Hi Dom,

> In Brief im trying to display the Averages of each Column for each
> individual Days results so far all the methods ive tried have either
> led to a "0" or the summing of the Entire collection rather than per
> day...i tried using variables but found it impossible to
> manipulate...i fear my xpath knowledge is letting me down ...

It looks as though you're trying to update variables, which of course
you can't do in XSLT. Try this:

<xsl:template match="Log">
  <xsl:variable name="LogsForDate" select="key('rows', @Date)" />
  <xsl:variable name="Count" select="count($LogsForDate)" />
  <table>
    ...
    <tr>
      <td bgcolor="#99CCCC">Averages:</td>
      <td bgcolor="#cccc99">
        <xsl:value-of select="round(sum($LogsForDate/@T_CPU) div $Count)"/>
      </td>
      ...
    </tr>
  </table>
</xsl:template>

The important thing is that you gather up all the logs for the
particular date in a variable, and then you use the sum() function to
sum whatever you want to sum in order to calculate the average.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.